Excel VBA代码中如何判断中文汉字 如何判断汉字后者中文开头 图文

2021年5月9日14:29:10Excel VBA代码中如何判断中文汉字 如何判断汉字后者中文开头 图文已关闭评论 1,536 views

Dim exp As String
Dim temp, tmpExp As String
Dim length As Integer

length = 0
tmpExp = ""

exp = Trim(xlsheet_TandE.cells(i, 8))
For j = 1 To Len(exp)

temp = Mid(exp, j, 1)
'判断是否是中文
If temp Like "[一-龥]" Then
'截取前26个半角字符
If length + 2 > 26 Then
Exit For
Else
length = length + 2
tmpExp = tmpExp & temp
End If

'判断是否是英文、数字、英文半角句号和空格
ElseIf temp Like "[0-9a-zA-Z. ]" Then
'截取前26个半角字符
If length + 1 > 26 Then
Exit For
Else
length = length + 1
tmpExp = tmpExp & temp
End If

End If
Next j

'将截取后的内容设定到"Explaination"中
xlsheet_TandE.cells(i, 8) = tmpExp
判断是中文开头

if x like "[一-龥]*" then

判断包含中文

if x like "*[一-龥]*" then

判断中文结束

if x like "[一-龥]*" then