程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> 編寫asp代碼截取字符串

編寫asp代碼截取字符串

編輯:關於ASP編程

       編寫asp代碼截取字符串:

      '函數名:SubstZFC

      '作 用:截字符串,漢字一個算兩個字符,英文算一個字符

      '參 數:str ----原字符串

      ' strlen ----截取長度

      '返回值:截取後的字符串

      '適用:標題截取指定字符,如果用LEFT截取,當有英文時就會出現取出來的標題明顯太短。

      '**************************************************

      Public Function SubstZFC(ByVal str, ByVal strlen)

      If str = "" Then

      SubstZFC = ""

      Exit Function

      End If

      Dim l, t, c, i, strTemp

      str = Replace(Replace(Replace(Replace(str, " ", " "), """, Chr(34)), ">", ">"), "<", "<")

      l = Len(str)

      t = 0

      strTemp = str

      strlen = CLng(strlen)

      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

      strTemp = Left(str, i)

      Exit For

      End If

      Next

      SubstZFC = Replace(Replace(Replace(Replace(strTemp, " ", " "), Chr(34), """), ">", ">"), "<", "<")

      End Function

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved