'------------------------------------------------------------
' Description: Let Len,left,right function recognize Chinese
' The Chinese is recognized as two characters and the ASCII code is a
' Use this function instead of the Len,left,right function
' Example: Lenx ("Chinese ren") = "7"
' Leftx ("Ren of China", 4) = "China"
' Rightx ("Ren of China", 5) = "Guo Ren"
Parameters
' Sstring string
' Llength length
' Return: string length, String, string
' Finishing: Kimsoft (jinqinghua@gmail.com)
' Time: 2005-05-24
' Modified: 2005-07-07
'------------------------------------------------------------
Public Function Lenx (ByVal sstring)
Lenx = 0
Dim Lngstringlen
Dim strcharstring
Dim I
Lngstringlen = Len (sstring)
strcharstring = ""
For i = 1 to Lngstringlen
strcharstring = Mid (sstring, I, 1)
If ASC (strcharstring) > 0 Then
Lenx = Lenx + 1
Else
Lenx = Lenx + 2
End If
Next
End Function
Public Function leftx (ByVal sstring, ByVal llength)
LEFTX = ""
If sstring = "" Or llength < 1 then Exit Function
Dim Lngstringlength
Dim strcharstring
Dim Lngcounter
Dim I
Lngstringlength = Len (sstring)
For i = 1 to Lngstringlength
strcharstring = Mid (sstring, I, 1)
LEFTX = LEFTX & strcharstring
If ASC (strcharstring) > 0 Then
Lngcounter = Lngcounter + 1
Else
Lngcounter = Lngcounter + 2
End If
If lngcounter >= Llength then Exit for
Next
End Function
Public Function rightx (ByVal sstring, ByVal llength)
RIGHTX = ""
If sstring = "" Or llength < 1 then Exit Function
Dim Lngstringlength
Dim strcharstring
Dim Lngcounter
Dim I
Lngstringlength = Len (sstring)
For i = Lngstringlength to 1 Step-1
strcharstring = Mid (sstring, I, 1)
RIGHTX = strcharstring & rightx
If ASC (strcharstring) > 0 Then
Lngcounter = Lngcounter + 1
Else
Lngcounter = Lngcounter + 2
End If
If lngcounter >= Llength then Exit for
Next
End Function