求VB统计数字出现频率的代码
来源:百度知道 编辑:UC知道 时间:2024/06/25 19:20:50
Dim intNumber(1 To 9) As Integer
Private Sub Command1_Click()
Dim intI As Integer
Dim intTemp As Integer
Dim intLen As Integer
Dim strTemp As String
'Text1 内容不为空
If Text1.Text <> "" Then
'取Text1 字串长度
intLen = Len(Text1.Text)
For intI = 1 To intLen
'分别取一个字符
strTemp = Mid(Text1.Text, intI, 1)
'---判断该字符是否为数字-------
If IsNumeric(strTemp) = True Then
intNumber(Val(strTemp)) = intNumber(Val(strTemp)) + 1
Else
End If
Next intI
Else
End If
strTemp = ""
List1.Clear
For intI = 1 To 9