'GB2312范围: 0xA1A1 - 0xFEFE
'GBK范围: 0x8140 - 0xFEFE
Public Function HIBYTE(ByVal Word As Integer) As Byte
HIBYTE = (Word And &HFF00&) \ &H100
End Function
Public Function LOBYTE(ByVal Word As Integer) As Byte
LOBYTE = Word And &HFF
End Function
'按GB2312提取中文字符
Function TiQu(str As String)
Dim i As Integer
Dim nAsc As Integer
Dim bytHigh As Byte
Dim bytLow As Byte
Dim strChar As String
Dim strTemp As String
For i = 1 To Len(str)
strChar = Mid(str, i, 1)
nAsc = Asc(strChar)
bytLow = LOBYTE(nAsc)
bytHigh = HIBYTE(nAsc)
If bytLow >= &HA1 And bytHigh >= &HA1 Then
strTemp = strTemp & strChar
End If
Next
TiQu = strTemp
End Function
'例
Sub Example1()
MsgBox TiQu("d中f国l;a世sjd界f;a")
End Sub
温馨提示:内容为网友见解,仅供参考