ASP中关于判断记录集字段是否到底的代码

来源:百度知道 编辑:UC知道 时间:2024/06/06 02:40:33
<% dim strselectsqldiary
set rs=server.createobject("adodb.recordset")
strselectdiary="select top 2 * from diary where isdiarybbs=0 order by diaryid desc"
rs.open strselectdiary,conn,3,1
%>
查找出来的记录中的一个字段名是content.在网页中用<%=rs("content")%>输出时想在第一行中输出25byte,如果多出则在下面几行中输出.帮我写出这个代码好吗?越详细越好.觉得好再追加分!

下面的代码你可以做成自定义方法,以备调用...
Dim tmpLen, i, rowLen
Dim tmpStr,contentr
rowLen = 25 //25字节,可以自己改这个值
tmpStr = Me.Text1
tmpLen = Len(tmpStr)
For i = 0 To tmpLen Step rowLen
contentr= contentr & iif(contentr="","","<br>") & Left(tmpStr, rowLen)
If Len(tmpStr) > rowLen Then
tmpStr = Right(tmpStr, Len(tmpStr) - rowLen)
End If
Next

<% dim strselectsqldiary
set rs=server.createobject("adodb.recordset")
strselectdiary="select top 2 * from diary where isdiarybbs=0 order by diaryid desc"
rs.open strselectdiary,conn,3,1
if not rs.eof then content=rs("content")
first_Row=left(content,25)
first_Row=first_Row+"<br>" '第一行输出25字节的时候换行
content=right(content,(len(content)-25))
content=first_Row+content

===================================

<%=content%>

%

能再补充说明一