还有一种方式,是检查串的比特长度:Dim strANSI As StringstrANSI = StrConv(strSource, vbFromUnicode)If Len(strtANSI) = LenB(strANSI) Then MsgBox "不是中文" Else MsgBox "有中文字符" End If
更正7 楼 of123 的回复:还有一种方式,是检查串的比特长度:Dim strSource As strinh Dim strANSI As String strSource="中文ABC" strANSI = StrConv(strSource, vbFromUnicode)If Len(strSource) = LenB(strANSI) Then MsgBox strSource+" 里面没有中文字符" Else MsgBox strSource+" 里面有中文字符" End If
逐字符(注意不是字节)取 Asc,如果是负数,就是汉字。
MsgBox "不是中文"
Else
MsgBox "有中文字符"
End If
Dim strANSI As String
strSource="中文ABC"
strANSI = StrConv(strSource, vbFromUnicode)If Len(strSource) = LenB(strANSI) Then
MsgBox strSource+" 里面没有中文字符"
Else
MsgBox strSource+" 里面有中文字符"
End If