vb题目:在文本框中输入一串数字字符串,统计出各数字出现的次数。
1个回答
展开全部
Private Sub Command1_Click()
Dim a(0 To 9) As Integer
For i = 1 To Len(Text1.Text)
a(Val(Mid(Text1.Text, i, 1))) = a(Val(Mid(Text1.Text, i, 1))) + 1
Next i
For i = 0 To 9
Label1(i) = "数字" & i & "出现" & a(i) & "次"
Next i
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And KeyAscii <> 8 Then
KeyAscii = 0
Beep
End If
End Sub
牙膏\5:看不懂吧?!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询