复制代码 代码如下: "************************************ "截取文字长度函数,支持UTF-8 "输入参数: " 1、文字内容 " 2、文字最大长度 "************************************ Public Function Cut_Title(Title,TLen) Dim k,i,d,c Dim iStr 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
"******************************* "检测文字长度函数,支持UTF-8 "输入参数: " 1、文字内容 "******************************* 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