vb题目:在文本框中输入一串数字字符串,统计出各数字出现的次数。

2026年09月28日 14:40
有1个网友回答
网友(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:看不懂吧?!