vb中输入一串字符,以回车键结束,分别统计其中大、小写字母个数、数字...
发布网友
发布时间:2024-10-23 21:32
我来回答
共1个回答
热心网友
时间:2024-10-27 05:12
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
Dim a, b, c
For inx = 1 To Len(Text1.Text)
If Asc(Mid(Text1.Text, inx, 1)) >= 48 And Asc(Mid(Text1.Text, inx, 1)) <= 57 Then a = a + 1
If Asc(Mid(Text1.Text, inx, 1)) >= 65 And Asc(Mid(Text1.Text, inx, 1)) <= 90 Then b = b + 1
If Asc(Mid(Text1.Text, inx, 1)) >= 97 And Asc(Mid(Text1.Text, inx, 1)) <= 122 Then c = c + 1
Next inx
MsgBox "小写字母:" & c & "个,大写字母:" & b & "个,数字:" & a & "个"
End If
End Sub