The interception text length function supports UTF-8, which can satisfy most friends who intercept strings. Copy the code code as follows:
'************************************
'Intercept text length function, supports UTF-8
'Input parameters:
' 1. Text content
' 2. Maximum text length
'************************************
Public Function Cut_Title(Title,TLen)
Dim k,i,d,c
ikB
Dim ForTotal
If CDbl(TLen) > 0 Then
k=0
d=StrLen(Title)
iStr=
ForTotal = Len(Title)
For i=1 To ForTotal
c=Abs(AscW(Mid(Title,i,1)))
If c>255 Then
k=k+2
Else
k=k+1
End If
iStr=iStr&Mid(Title,i,1)
If CLng(k)>CLng(TLen) Then
iStr=iStr..
Exit For
End If
Next
Cut_Title=iStr
Else
Cut_Title=
End If
End Function
'******************************
'Detect text length function, supports UTF-8
'Input parameters:
' 1. Text content
'******************************
Public Function StrLen(strText)
Dim k,i,c
Dim ForTotal
k=0
ForTotal = Len(strText)
For i=1 To ForTotal
c=Abs(AscW(Mid(strText,i,1)))
If c>255 Then
k=k+2
Else
k=k+1
End If
Next
StrLen=k
End Function