求一段VB的代码,题目是“在文本框中输入一串数字字符串,统计出各数字出现的次数。”
展开全部
Private Sub Command1_Click()
Dim i%, t%
Dim s As String
Dim n(9) As Integer
s = Text1
For i = 1 To Len(s)
t = Val(Mid(s, i, 1))
n(t) = n(t) + 1
Next
For i = 0 To 9
Print i & "有" & n(i) & "个"
Next
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
Dim i%, t%
Dim s As String
Dim n(9) As Integer
s = Text1
For i = 1 To Len(s)
t = Val(Mid(s, i, 1))
n(t) = n(t) + 1
Next
For i = 0 To 9
Print i & "有" & n(i) & "个"
Next
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询