4,asp中应用
以上是在客户端脚本调试,和asp也是大同小异:最主要的是函数功能。
<%
text=rs("content") '将数据库字段值赋到某变量上
i=10 '定义固定大小
if len(text)>i then '如果文本长度大于给定的值
text=left(text,i) '则提取前段的i位的字符串
response.write (text&"...")
else
response.write (text)
end if
%>
5,为了方便,做成函数
<% function conleft(content,i) if len(content)>i then content=left(content,i) response.write (content&"...") else response.write (content) end if end function %> |
以上为函数,下面就可以直接调用。
<%call conleft(rs("content"),10)%> |
ok,相信以后遇到这些问题应该是no problem
为了解决中英文截取的问题,建议大家使用如下函数:
function gottopic(str,strlen) if str="" then gottopic="" exit function end if dim l,t,c, i str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<") l=len(str) t=0 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 gottopic=left(str,i) & "…" exit for else gottopic=str end if next gottopic=replace(replace(replace(replace(gottopic," "," "),chr(34),"""),">",">"),"<","<") end function |
如对本文有疑问, 点击进行留言回复!!
asp中Request.ServerVariables的参数集合
网友评论