一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp 中西文混合式字符截取程序

时间:2022-07-02 22:32:50 编辑:袖梨 来源:一聚教程网

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

热门栏目