【www.gdgbn.com--php常用代码】

 
 Public Function CutStr(byVal val,byVal length,byVal endStr)
  Dim l,t,c,i
  If val = "" Or IsNull(val) Then
   CutStr = ""
   Exit Function
  End If
  If length = "" Or Int(length) <= 0 Or IsNumeric(length) = False Then
   CutStr = val
   Exit Function
  End If
  val = LoseHTML(val)
  l = Len(val)
  length = Int(length)
  t = 0
  For i = 1 To l
   c = Ascw(Mid(val,i,1))
   If c < 0 Or c > 255 Then t = t + 2 Else t = t + 1
   IF t >= length Then
    CutStr = Left(val,i) & endStr
    Exit For
   Else
    CutStr = val
   End If
  Next
 End Function
 
 Public Function LoseHtml(ContentStr)
  If ContentStr = "" Or IsNull(ContentStr) Or IsEmpty(ContentStr) Then
   LoseHtml = ""
  Else
   Dim tempLoseStr,regEx
   tempLoseStr = Cstr(ContentStr)
   Set regEx = New RegExp
   regEx.Pattern = "]*>"
   regEx.IgnoreCase = True
   regEx.Global = True
   tempLoseStr = regEx.Replace(tempLoseStr,"")
   LoseHtml = tempLoseStr
  End if
 End Function

本文来源:http://www.gdgbn.com/jiaocheng/23742/