熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp字符串截取函數

2013-11-13 10:37:18  來源: .NET編程 

  本文章提供這款asp字符串截取函數原是是先用定義字符串判別函數判斷字符串長度以及中英文再把字符截取後定義超出部分內容的顯示方式

  function strvalue(strlennum)
           dim p_num
           dim i
           if strlen(str)<=lennum then
           strvalue=str
           else
           p_num=
           x=
           do while not p_num > lennum
           x=x+
           if asc(mid(strx))< then
           p_num=int(p_num) +
           else
           p_num=int(p_num) +
           end if
           strvalue=left(trim(str)x)&"…" 截取後定義超出部分內容的顯示方式
           loop
           end if
           end function

  定義字符串判別函數

  function strlen(str)
           dim p_len
           p_len=
           strlen=
           if trim(str)<>"" then
           p_len=len(trim(str))
           for xx= to p_len
           if asc(mid(strxx))< then
           strlen=int(strlen) +
           else
           strlen=int(strlen) +
           end if
           next
           end if
           end function

  截取字符串包括前後字符串不包括前後字符串
           function strcut(strcontentstartstrendstrcuttype)
           dim ss
           on error resume next
           select case cuttype
           case
             s = instr(strcontentstartstr)
             s = instr(sstrcontentendstr)+len(endstr)
           case
             s = instr(strcontentstartstr)+len(startstr)
             s = instr(sstrcontentendstr)
           end select
           if err then
             strcute = "<p align=center ><font size=>截取字符串出錯</font></p>"
             errclear
             exit function
           else
             strcut = mid(strcontentsss)
           end if
           end function


From:http://tw.wingwit.com/Article/program/net/201311/14142.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.