简介:复制代码 代码如下: '************************************ '截取文字长度函数,支持UTF-8 '输入参数: ' 1、文字内容 ' 2、文字最大长度 '************************************ Public Function Cut_Title(Title,TLen) Dim k,i,d,c Dim iStr Dim ForTotal……
'************************************
'截取文字长度函数,支持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
End Function
原文链接:https://m.jb51.net/article/18199.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!