简单的一种
以下是代码片段:
<%
if len(rs("title")) > 10 then ’判断字符串的长度
response.Write left(rs("title"),9)&" ..."
else
response.write rs("title")
end if
%>
| 函数的: Function InterceptString(text,length) ’函数名 text=trim(text) ’忽略字符串前后的空白 text_length= len(text) ’求字符串的长度 count_length = 0 ’用来计数 if text_length >= 1 then for count= 1 to text_length ’这一个循环计算要截取的字符串 if asc(mid(text,ii,1)) < 0 or asc(mid(text,ii,1)) >255 then ’如果是汉字 count_length = count_length + 2 else count_length = count_length + 1 end if if count_length >= length then text = left(trim(text),count) ’字符串限长 exit for end if next InterceptString = text ’函数返回值 else InterceptString = "" end if End Function |
3065

被折叠的 条评论
为什么被折叠?



