判斷字符串中是否含有中文字符
一般是利用ASC碼來判斷字符是中文還是英文,如果是中文,ASC碼小于0,而英文則是大于0。依據這個思路,相應的VB code如下:
Private Function HasChineseInString(textstring As String) As Boolean
Dim i As Integer
For i = 1 To Len(textstring)
If Asc(Mid(textstring, i, 1)) < 0 Then
' if chiness
HasChineseInString= True
Exit function
End If
Next
HasChineseInString=False
End Function
Dim i As Integer
For i = 1 To Len(textstring)
If Asc(Mid(textstring, i, 1)) < 0 Then
' if chiness
HasChineseInString= True
Exit function
End If
Next
HasChineseInString=False
End Function
-----------------------------------------------------------
佛对我说:你心里有尘。我用力的拭擦。