中西文混合式字符截取程序
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