您的位置首页百科知识

vb 判断text中内容是汉字还是字母还是数字

vb 判断text中内容是汉字还是字母还是数字

给你弄个完整的吧!

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

抖音看短剧