展开全部
在某个窗体建一个文本框Text1
在按钮单击代码中粘贴下面代码
Private Sub Command2_Click()
Dim I As Integer
Dim txt As String
Dim atxt As String
Dim ascii As Integer
Dim intLen As Integer
Dim intChar As Integer
Dim intNum As Integer
Dim intOther As Integer
txt = Text1
intLen = Len(txt)
For I = 1 To intLen
atxt = Mid(txt, I, 1)
ascii = Asc(atxt)
Select Case ascii
Case 65 To 90
intChar = intChar + 1
Case 48 To 57
intNum = intNum + 1
Case 97 To 122
intChar = intChar + 1
Case Else
intOther = intOther + 1
End Select
Next I
MsgBox ("字母" & intChar & "个,数字" & intNum & "个,其他" & intOther & "个")
End Sub
在按钮单击代码中粘贴下面代码
Private Sub Command2_Click()
Dim I As Integer
Dim txt As String
Dim atxt As String
Dim ascii As Integer
Dim intLen As Integer
Dim intChar As Integer
Dim intNum As Integer
Dim intOther As Integer
txt = Text1
intLen = Len(txt)
For I = 1 To intLen
atxt = Mid(txt, I, 1)
ascii = Asc(atxt)
Select Case ascii
Case 65 To 90
intChar = intChar + 1
Case 48 To 57
intNum = intNum + 1
Case 97 To 122
intChar = intChar + 1
Case Else
intOther = intOther + 1
End Select
Next I
MsgBox ("字母" & intChar & "个,数字" & intNum & "个,其他" & intOther & "个")
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |