用vb编程:在文本框中输入一个字符串,统计其中的大写英文、小写英文、数字及其他字符各有多少个。
请大侠们把格式写好一点二楼的你说的是不是就像这样Fori=1ToLen(Text1.Text)x=Mid(Text1.Text,i,1)IfIsNumeric(x)The...
请大侠们把格式写好一点
二楼的你说的是不是就像这样
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 展开
二楼的你说的是不是就像这样
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 展开
4个回答
展开全部
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
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
展开全部
大小写的情形用ASC码即可进行判断。数字的做卜话,可以用团裂isnumeric()函数进行判断,其他字符的话,其实就是总的字符数减塌胡闭去上述各种情形的和即可。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询