注册 登录
编程论坛 ASP技术论坛

谁能给个截取字符的函数?

nicechlk 发布于 2008-11-10 00:21, 589 次点击
例:
title=rs("title")
if len(title) > 20 then
  title=left(title,20)&"..."
end if
response.write title

我不想每次都这样写,能给个函数吗?谢谢!
ps:把那个20的长度也盖进函数里。
1 回复
#2
hmhz2008-11-10 08:04
自己写就是了,很简单的,只是把页面程序里的执行过程放到函数组里运行就是了
<%
Function Trim2(ke2)
if len(ke2)>20 then
  Trim2=left(ke2,20)&"..."
end if
End Function
%>
调用的时候: <%=Trim2(rs("title"))%>
1