vb字符串中提取数字?
答案:1 悬赏:50 手机版
解决时间 2021-03-16 01:07
- 提问者网友:伴风望海
- 2021-03-15 18:00
vb字符串中提取数字?
最佳答案
- 五星知识达人网友:十鸦
- 2021-03-15 18:14
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
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
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯