当前位置:首页 > 程序&理念 >

asp函数截取字符串

时间:2006-12-10 11:45:43浏览:60520 转载

asp函数截取字符串
<%
Function InterceptString(txt,length)
txt=trim(txt)
x = len(txt)
y = 0
if x >= 1 then
for ii = 1 to x
if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then '如果是汉字
y = y + 2
else
y = y + 1
end if
if y >= length then
txt = left(trim(txt),ii) '字符串限长
exit for
end if
next
InterceptString = txt
else
InterceptString = ""
end if
End Function
%>

<%
'调用
InterceptString(Rs("title"),20)
%>

上一篇:ajax资料收集
下一篇:让广告代码不再影响你的网页加载速度

发表评论

昵称:  验证码:

关于博主

博主

博主:BlueCode

职业:web程序

简介:2002年开始一直从事Web制作,网站运营,会PHP+MYSQL ASP+MSSQL,微信开发