vb字符串中提取数字?
1个回答
展开全部
Private Sub Command1_Click()
Dim s As String, k As Integer, c() As String
Dim p As String, i As Integer
s = Text1.Text
k = 1
For i = 1 To Len(s)
If Mid(s, i, 1) >= "0" And Mid(s, i, 1) <= "9" Then
p = p & Mid(s, i, 1)
ElseIf Mid(s, i + 1, 1) >= "0" And Mid(s, i + 1, 1) <= "9" And i <> 1 Then
If p <> "" Then
ReDim Preserve c(k)
c(k) = p
k = k + 1
p = ""
End If
End If
Next i
ReDim Preserve c(k)
c(k) = p
For i = 1 To k
List1.AddItem (c(i))
Next i
End Sub
Private Sub Form_Load()
Text1.Text = "abc123d4fr567yh89l09df4m67dkj21"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询