Office中国论坛/Access中国论坛

标题: 又一个判断中英文的方法 [打印本页]

作者: tmtony    时间: 2002-6-17 04:46
标题: 又一个判断中英文的方法
使用方法:chkGB("Access中国")
返回:英英英英英英简简

Private Function chkGb(strGB As String) As String
On Error Resume Next
Dim ByteGB() As Byte
Dim ByteTemp(1) As Byte
Dim leng As Long, idx As Long
Dim Offset As Long
Dim strResult As String
ByteGB = StrConv(strGB, vbFromUnicode)
leng = UBound(ByteGB)
idx = 0
Do While idx <= leng
    ByteTemp(0) = ByteGB(idx)
    ByteTemp(1) = ByteGB(idx + 1)
    Offset = GBOffset(ByteTemp)
    If (Offset >= 0) And (Offset <= 8177) Then
        strResult = strResult & "简"
        idx = idx + 2
    Else
        strResult = strResult & "英"
        idx = idx + 1   
    End If
Loop
chkGb = strResult

End Function
Private Function GBOffset(ChrString() As Byte) As Long

    Dim Dl, Dh
    Dl = ChrString(0)
    Dh = ChrString(1)
    GBOffset = (Dl - 161) * 94 + (Dh - 161)
End Function

作者: sdlhlsd    时间: 2002-6-17 05:04
标题: 好东西!
好东西!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3