VB程序编写,统计从文本框输入的字符串中的字母数字空格和其他字符的个数由不同文本框显示个数
来源:百度知道 编辑:UC知道 时间:2024/05/21 23:01:41
Private Sub Command1_Click()
Dim str As String, strTmp As String, intN As Integer, intM As Integer
Dim intX As Integer, intY As Integer, intZ As Integer, intW As Integer
str = Text1.Text
intN = Len(str)
For intM = 1 To intN
strTmp = UCase(Mid(str, intM, 1))
If IsNumeric(strTmp) Then '数字
intX = intX + 1
ElseIf Asc(strTmp) > 64 And Asc(strTmp) < 91 Then '字母
intY = intY + 1
ElseIf strTmp = " " Then '空格
intZ = intZ + 1
Else '其它
intW = intW + 1
End If
Next
Text2.Text = "数字个数为:" & intX
Text3.Text = "字母个数为:" & intY
Text4.Text = "空格个数为:" & intZ
Text5.Text = "特殊字符个数为:" & intW
End Sub
'如果满意我的回答,请采纳.谢谢
'写错了 我改了下
function stABC(word)'字母