asp 获取字符串长度函数

来源:互联网 发布:常用的非线性优化算法 编辑:程序博客网 时间:2024/06/10 12:01
  1. Function GetLength(strChinese1)
  2.   Dim strWord, ascWord, lenTotal
  3.   strChinese1 = Trim(strChinese1)
  4.   If strChinese1 = "" or Vartype(strChinese1) = vbNull then
  5.     GetLength = 0
  6.     Exit Function
  7.   End If
  8.   lenTotal = 0 
  9.   For GetLengthi=1 to Len(strChinese1)
  10.     strWord = Mid(strChinese1, GetLengthi, 1)
  11.     ascWord = Asc(strWord)
  12.     If ascWord < 0 or ascWord > 127 then
  13.       lenTotal = lenTotal + 2
  14.     Elseif ascWord = 63 And strWord <> "?" then
  15.       lenTotal = lenTotal + 2
  16.     Elseif ascWord = 44 And strWord <> "," then
  17.       lenTotal = lenTotal + 2
  18.     Elseif ascWord = 33 And strWord <> "!" then
  19.       lenTotal = lenTotal + 2
  20.     Else
  21.       lenTotal = lenTotal + 1
  22.     End If
  23.   Next
  24.   GetLength = lenTotal
  25. End Function
asp 获取字符串长度函数

 

 

 

原创粉丝点击