Private Sub Command1_Click() Dim s As String Dim dd As String '用于保存结果 Dim i As Integer Dim k As Integer s = "真光路798弄33号201室" k = InStr(s, "室") '判断 室 在字符串中的位置 For i = k - 1 To 1 Step -1 '从后往前取出数字 If IsNumeric(Mid(s, i, 1)) Then dd = Mid(s, i, 1) & dd Else Exit For End If Next MsgBox dd End Sub追问
s="798弄33号201室" l=instr(s,"室") do while l>0 i=0 do t=mid(s,l-i,1) ys=0 i=i+1 select case t case "0" to "9" ss=t&ss ys=1 end select loop while ys if ss<>"" then exit do else l=instr(l,s,"室") end if loop msgbox ss 手机打的,应该没有问题