vb中统计数字的和
,怎么在输入的一串东西如:ab12a25c12 只统计数字的和?代码怎么做
Private Sub Command1_Click()
试试
Dim temp As String
Dim x As String
Dim i As Integer
Dim sum As Integer
temp = Text1.Text
For i = 1 To Len(temp)
x = Mid(temp, i, 1)
If Asc(x) >= 48 And Asc(x) <= 57 Then sum = sum + Asc(x) - Asc(0)
Next
Form1.Caption = sum
End Sub