ASP 标题限制字数菜鸟问题

来源:百度知道 编辑:UC知道 时间:2024/07/04 21:39:33
菜鸟学习ASP
想在这段代码修改成为能限制标题字数
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from cygl where type=1 order by dates desc",conn,1,1
if rs.eof then
response.Write("当前没有信息!!")
else
i=1
do while not rs.eof and i<9

%>
<%
rs.movenext
i=i+1
loop
end if
rs.close
set rs=nothing
i=0

%>

left(rs("标题列"),x) left是左函数,x是你要的标题列的前面位数,如
left(rs("title"),10):要title的前面10个字。

还有,你的这个大体意思是要前面的8条信息,这样写会简单一些:
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select top 8 * from cygl where type=1 order by dates desc",conn,1,1
if rs.eof then
response.Write("当前没有信息!!")
else
do while not rs.eof
%>
<%
rs.movenext
loop
end if
rs.close
set rs=nothing
%>

<%=left(rs("title"),20) %>

<%
Function InterceptString(txt,length)
dim x,y,ii
txt=trim(txt)
x = len(txt)
y = 0
if x >= 1 then
for ii = 1 to x
if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then
y = y + 2
else
y = y + 1
end if
if clng(y)>=clng(length) then
txt = left(trim(txt),ii)
InterceptString = txt