ASP自动,截断,文字,的问题!

来源:百度知道 编辑:UC知道 时间:2024/05/27 14:23:03
我一个标题的名字,共20个字,我要把前面的10数字自动截断,只留后面的10个,同时,如果后面的10个大于8个时自动截断后面的,也就是要截断两次,第一次截前面的10个,到了18时截断后面的,请问如何弄?最好是把说明也写上!
请参考我下面的帮我修改一下!搞定分全送上!
<%response.write "<a class=a1 href=info/"&rs("id")&".asp >"
if len(trim(rs("name")))>11 then
response.write right(trim(rs("name")),10)&".."
else
response.write trim(rs("name"))
end if
response.write "</a>"
%>

<%
response.write "<a class=a1 href=info/"&rs("id")&".asp >"
if len(trim(rs("name")))>18 then
response.write mid(trim(rs("name")),18)&".." '取第18个后面的字符
elseif len(trim(rs("name")))>10 then
response.write mid(trim(rs("name")),10)&".." '取第10个后面的字符
else
response.write trim(rs("name"))
end if
response.write "</a>"
%>

Mid 函数
从字符串中返回指定数目的字符。

Mid(string, start[, length])

参数
string

字符串表达式,从中返回字符。如果 string 包含 Null,则返回 Null。

Start

string 中被提取的字符部分的开始位置。如果 start 超过了 string 中字符的数目,Mid 将返回零长度字符串 ("")。

Length

要返回的字符数。如果省略或 length 超过文本的字符数(包括 start 处的字符),将返回字符串中从 start 到字符串结束的所有字符。

<%response.write "<a class=a1 href=info/"&rs("id")&".asp >"<