'请问如何在VB中或者sqlServer中判断一个字符串中是否含有汉字。
'注:字符串中有可能含有日语字符,或者全角模式下的特殊字符(如破折号等),这些都不视为汉字。
出处地址: @L_404_0@
Private Sub Command1_Click()
Dim strSample As String,i As Long
'strSample = "ffdddd中国vbxxx"
strSample = "ffdddd--vbxxx"
For i = 1 To Len(strSample)
If WhatChar(Mid(strSample,i,1)) > 0 Then
MsgBox "含有汉字"
Exit For
End If
Next
End Sub
Private Function WhatChar(ByVal vStr As String) As Integer Dim gbascii As Byte Dim intChar As Integer If Asc(vStr) < 0 Then gbascii = AscB(StrConv(vStr,vbFromUnicode)) If gbascii - 160 > 15 Then intChar = 1 ' 汉字 Else intChar = 0 ' 全角符号 End If Else intChar = 0 ' 半角英文或数字 End If WhatChar = intCharEnd Function
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。