取指定字符串的指定长度

来源:互联网 发布:java 8中文版实战 编辑:程序博客网 时间:2024/04/30 02:58

 取指定字符串的指定长度

 

Function ShowText(Text)
  If IsNull(Text) Or Text="" Then Exit Function
  Text=replace(Text,"<br>","")
  Text=c(Text,chr(32),"")
  Text=replace(Text,chr(13),"")
  Text=replace(Text,chr(10),"")
  Text=replace(Text,chr(10),vbcrlf)
  Text=replace(Text,chr(9),"")
  ShowText=replace(Text,"&nbsp;","")
 End Function
 
 Function CutStr(str,strlen) 
  Dim l,t,c,i
  str=ShowText(str)
  l=len(str)
  t=0
  For i=1 To l
   c=Abs(Asc(Mid(str,i,1)))
   If c>255 Then
    t=t+2
   Else
    t=t+1
   End If
   If t>=strlen Then
    cutStr=left(str,i)&"..."
    Exit for
   Else
    cutStr=str
   End If
  Next
  Str = Empty
 End Function

原创粉丝点击