用vb编程:在文本框中输入一个字符串,统计其中的大写英文、小写英文、数字及其他字符各有多少个。

请大侠们把格式写好一点
二楼的你说的是不是就像这样
For i = 1 To Len(Text1.Text)
x = Mid(Text1.Text, i, 1)
If IsNumeric(x) Then
s1 = s1 + 1
ElseIf Asc(x) <= 122 And Asc(x) >= 97 Then
s2 = s2 + 1
ElseIf Asc(x) <= 90 And Asc(x) >= 65 Then
s3 = s3 + 1
Else
s4 = s4 + 1
End If
Print s1,s2,s3,s4

Option Explicit

Private Sub Command1_Click()
Dim i As Integer
Dim stra As String
Dim a As Integer
For i = 1 To Len(Text1.Text)
stra = Mid(Text1.Text, i, 1)

MsgBox "当前字母为:" & stra & " 添加分析即可"

'利用ASC的值区分字母数字字符等,因为要统计的太多了不多说,只教方法
' if Asc(stra)= 91 then

Next

End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-11-12
大小写的情形用ASC码即可进行判断。数字的话,可以用isnumeric()函数进行判断,其他字符的话,其实就是总的字符数减去上述各种情形的和即可。本回答被提问者采纳
第2个回答  2019-12-09
Private
Sub
Command1_Click()
For
i
=
1
To
Len(Text1.Text)
stemp
=
Mid(Text1.Text,
i,
1)
If
IsNumeric(stemp)
Then
S1
=
S1
+
1
If
Asc(stemp)
<=
122
And
Asc(stemp)
>=
97
Then
S2
=
S2
+
1
If
Asc(stemp)
<=
90
And
Asc(stemp)
>=
65
Then
S3
=
S3
+
1
Next
'S1个数字,,s2个小写
s3个大写
End
Sub
第3个回答  2009-11-12
Dim textValue As String
Dim textLth As Integer
Dim CharValue As Integer
Dim UpperCaseChar As Integer
Dim lowerCaseChar As Integer
Dim NumberChar As Integer
Dim otherChar As Integer

textValue = Text1.Text
textLth = Len(textValue)
For i = 1 To textLth
CharValue = Asc(Mid(textValue, i, 1))
Select Case CharValue
Case 65 To 90
UpperCaseChar = UpperCaseChar + 1
Case 97 To 122
lowerCaseChar = lowerCaseChar + 1
Case 48 To 57
NumberChar = NumberChar + 1
Case Else
otherChar = otherChar + 1
End Select
Next

MsgBox "大写:" & UpperCaseChar & " 小写" & lowerCaseChar & _
" 数字:" & NumberChar & " 其他:" & otherChar