天枫常用的ASP函数封装如下

2019-01-13 12:34:05王振洲

 '****************************************************
 '函数名:CutStr
 '作  用:字符串长度切割,超过显示省略号
 '参  数:str    ----字符串内容
 '       strlen ------要显示的长度
 '返回值:切割后字符串内容
 '****************************************************
 Public Function CutStr(str,strlen)
     Dim l,t,i,c
     If str="" Then
     cutstr=""
     Exit Function
     End If
     str=Replace(Replace(Replace(Replace(Replace(str," "," "),""",Chr(34)),">",">"),"<","<"),"|","|")
     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
     cutstr=Replace(Replace(Replace(Replace(replace(cutstr," "," "),Chr(34),"""),">",">"),"<","<"),"|","|")
  End Function

'--------------系列验证----------------------------

    '****************************************************
 '函数名:CheckIsEmpty
 '作  用:检查是否为空
 '参  数:tstr ----字符串
 '返回值:true不为空,false为空
 '****************************************************
 Public Function CheckIsEmpty(tstr)
  CheckIsEmpty=false
  If IsNull(tstr) or Tstr="" Then Exit Function 
  Dim Str,re
  Str=Tstr
  Set re=new RegExp
  re.IgnoreCase =True
  re.Global=True
  str= Replace(str, vbNewLine, "")
  str = Replace(str, Chr(9), "")
  str = Replace(str, " ", "")
  str = Replace(str, " ", "")
  re.Pattern="<img(.[^>]*)>"
  str =re.Replace(Str,"94kk")
  re.Pattern="<(.[^>]*)>"
  Str=re.Replace(Str,"")
  Set Re=Nothing
  If Str<>"" Then CheckIsEmpty=true
 End Function