回 帖 发 新 帖 刷新版面

主题:这段代码什么意思啊,大虾们帮忙看看,谢谢

也不知道是什么意思啊

<%
function cutstr(tempstr,tempwid)
if len(tempstr)>tempwid then
cutstr=left(tempstr,tempwid)&"..."
else
cutstr=tempstr
end if
end function%>

回复列表 (共2个回复)

沙发

结果是:
 123123123123123...
只显示指定字数的文字,多余的用省略号

板凳

<%
function cutstr(tempstr,tempwid)'定义一个函数,有两个参数tempstr是字符串,tempwid是数字
if len(tempstr)>tempwid then '如果传入的字符串长度大于指定大小
cutstr=left(tempstr,tempwid)&"..." '把原字符串取前指定位数加上...然后赋给cutstr
else'否则
cutstr=tempstr  'cutstr的值就是字符串
end if
end function%>

我来回复

您尚未登录,请登录后再回复。点此登录或注册