VB编程:用InputBox函数输入一个由数字0到9组成的字符串,统计其中每个数字出现的次数

如题所述

Private Sub Command1_Click()
Dim s As String
Dim a(9) As Integer
s = InputBox("请输入数字字符串")
If IsNumeric(s) Then
For i = 1 To Len(s)
a(Mid(s, i, 1)) = a(Mid(s, i, 1)) + 1
Next i
Print "数字", "出现次数"
For i = 0 To UBound(a)
Print i, a(i)
Next i
Else
MsgBox "输入的字符不符合要求"
End If
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-12-04
10
相似回答