1个回答
展开全部
给你弄个完整的吧!
Private Sub Command1_Click()
Dim nStr$, dStr$, StrN%, Cyc%, CntN%(3)
nStr = Trim(Text1.Text)
StrN = Len(nStr)
For Cyc = 1 To StrN
Select Case Asc(Mid(nStr, Cyc, 1))
Case 65 To 90, 97 To 122
CntN(0) = CntN(0) + 1
Case 48 To 57
CntN(1) = CntN(1) + 1
Case Is < 0
CntN(2) = CntN(2) + 1
Case Else
CntN(3) = CntN(3) + 1
End Select
Next
MsgBox "数字有:" & CntN(0) & "个" & vbLf & "字母有:" & CntN(1) & "个" & vbLf & "汉字有:" & CntN(2) & "个" & vbLf & "其它字符有:" & CntN(3) & "个"
End Sub
Private Sub Command1_Click()
Dim nStr$, dStr$, StrN%, Cyc%, CntN%(3)
nStr = Trim(Text1.Text)
StrN = Len(nStr)
For Cyc = 1 To StrN
Select Case Asc(Mid(nStr, Cyc, 1))
Case 65 To 90, 97 To 122
CntN(0) = CntN(0) + 1
Case 48 To 57
CntN(1) = CntN(1) + 1
Case Is < 0
CntN(2) = CntN(2) + 1
Case Else
CntN(3) = CntN(3) + 1
End Select
Next
MsgBox "数字有:" & CntN(0) & "个" & vbLf & "字母有:" & CntN(1) & "个" & vbLf & "汉字有:" & CntN(2) & "个" & vbLf & "其它字符有:" & CntN(3) & "个"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询