如何限制td内输出字数?
如何限制<td>内输出50字
[解决办法]
这个用vbscript函数很简单呀,比如你要输出记录集rs中 field字段的前50个字符:
<td><%=left(rs("field"),50)%></td>
[解决办法]
给你个函数
'**************************
'函数名: Cut_String
'参 数:s_strsrc: 字符串
'参 数:length: 限定长度
'参 数:points: true为有"...",false为无
'返 回: String
'作 用:截断字符串
'**************************
function cut_string(byval s_strsrc, byval i_length, byval b_points)
dim x, y, i, txt
if trim(s_strsrc) = "" or isnull(s_strsrc) then
cut_string = ""
exit function
end if
txt = Replace(Replace(Replace(Replace(s_strsrc," "," "),""",Chr(34)),">",">"),"<","<")
x = len(txt)
y = 0
if x >= 1 then
for i = 1 to x
if asc(mid(txt, i, 1)) < 0 or asc(mid(txt, i, 1)) > 255 then '如果是汉字
y = y + 2
else
y = y + 1
end if
if y >= i_length then
if b_points then
txt = left(txt, i) & "..."
else
txt = left(txt, i)
end if
exit for
end If
next
cut_string = txt
else
cut_string = ""
end If
end function