asp截取字符串函数_asp怎么截取字符串

216 阅读1分钟

asp截取字符串函数_asp怎么截取字符串

'截取字符串 strvalue(标题,字数)
<%
function strvalue(str,lennum)
     dim p_num
     dim i
     if strlen(str)<=lennum then
         strvalue=str
     else
         p_num=0
         x=0
         do while not p_num > lennum-2
             x=x+1
             if asc(mid(str,x,1))<0 then
                 p_num=int(p_num) + 2
             else
                 p_num=int(p_num) + 1
             end if
             strvalue=left(trim(str),x)&"…"
         loop
     end if
 end function
 function strlen(str)
     dim page_len
     page_len=0
     strlen=0
     if trim(str)<>"" then
         page_len=len(trim(str))
         for xx=1 to page_len
         if asc(mid(str,xx,1))<0 then
             strlen=int(strlen) + 2
         else
             strlen=int(strlen) + 1
         end if
         next
     end if
 end function
%>

引用

<%=strvalue("准确的编程语言,可正确对代码语法着色,输入简单几个字的代码片段说明",10)%>


\

原文地址:www.jb51.net/article/624…

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\

\