在文本框中输入一个字符串,统计其中的大写英文、小写英文、数字及其他字符各有多少个。
答案:1 悬赏:30 手机版
解决时间 2021-05-07 22:24
- 提问者网友:你挡着我发光了
- 2021-05-07 14:13
在文本框中输入一个字符串,统计其中的大写英文、小写英文、数字及其他字符各有多少个。
最佳答案
- 五星知识达人网友:狂恋
- 2021-05-07 14:56
Private Sub Command1_Click()
Dim s As String
Dim c As String
Dim i As Integer
Dim uc As Integer
Dim lc As Integer
Dim nc As Integer
Dim oc As Integer
s = Text1.Text
For i = 1 To Len(s)
c = Mid(s, i, 1)
If "A" <= c And c <= "Z" Then
uc = uc + 1
ElseIf "a" <= c And c <= "z" Then
lc = lc + 1
ElseIf "0" <= c And c <= "9" Then
nc = nc + 1
Else
oc = oc + 1
End If
Next
MsgBox "大写英文:" & uc & vbCrLf & "小写英文:" & lc & vbCrLf & "数字:" & nc & vbCrLf & "其他字符:" & oc
End Sub
Dim s As String
Dim c As String
Dim i As Integer
Dim uc As Integer
Dim lc As Integer
Dim nc As Integer
Dim oc As Integer
s = Text1.Text
For i = 1 To Len(s)
c = Mid(s, i, 1)
If "A" <= c And c <= "Z" Then
uc = uc + 1
ElseIf "a" <= c And c <= "z" Then
lc = lc + 1
ElseIf "0" <= c And c <= "9" Then
nc = nc + 1
Else
oc = oc + 1
End If
Next
MsgBox "大写英文:" & uc & vbCrLf & "小写英文:" & lc & vbCrLf & "数字:" & nc & vbCrLf & "其他字符:" & oc
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯