vb题目 急急急!!!!!!
来源:百度知道 编辑:UC知道 时间:2024/09/12 22:17:48
2.编写一个程序:从键盘输10个字符,分别统计出其中大写字母、小写字母、数字字符、空格字符和其他字符的个数
100% 你的要求
创建一个text 复制下面代码即可
Dim t1, t2, t3 As Integer
Private Sub Text1_Change()
If Len(Text1.Text) >= 10 Then
t1 = 0: t2 = 0: t3 = 0
For i = 1 To 10
Select Case Asc(Mid(Text1.Text, i, 1))
Case Asc("a") To Asc("z"): t1 = t1 + 1
Case Asc("A") To Asc("Z"): t2 = t2 + 1
Case Asc("0") To Asc("9"): t3 = t3 + 1
End Select
Next i
MsgBox "有" & t1 & "个小写字母," & t2 & "个大写字母," & t3 & "个数字,"
TEXT1.TEXT=""
End If
End Sub
Private Sub Command1_Click()
Dim daxie, xiaoxie, shuzi, kongge As Integer
For i = 1 To 10
S = Asc(Mid(Text1.Text, i, 1))
If S = 32 Then kongge = kongge + 1
If S <= 122 And S >= 97 Then xiaoxie = xiaoxie + 1
If S <= 90 And S >= 65 Then daxie = daxie + 1
If S <= 57 And S >= 48 Then shuzi = shuzi + 1
Next
MsgBox "大写