注册 登录
编程论坛 ASP技术论坛

asp长文章分页显示问题

qpl4226 发布于 2008-01-07 16:24, 768 次点击
我用下面的代码给长文章内容分页,结果是成功了,就是每20行分一页,但如果哪个文章的内容不够20行就显示不出来,另外文章内容超过20行的可以显示出来但分页后的最后一页也因为不够20行也无法显示出来
 
提示错误类型
错误类型:
Microsoft VBscript.... 运行时错误 (0x800A0009)
下标越界: 'i'
希望朋友门帮忙看看是那里的问题

<% dim page,pagecount,thispage,linenum,allline

const pageline=20 ''每页显示20行
linenum=split(content,"<br>") ''本例为计算字符串<br>标记的个数
allline=ubound(linenum)+1 ''全文<br>(换行标记)总数
pagecount=int(allline\pageline)+1 ''计算总页数
page=request("page")
if isempty(page) then
thispage=1
else
thispage=cint(page)
end if
for i=1 to allline
if i+1>thispage*pageline-pageline and i<thispage*pageline then
response.write linenum(i) &"<br>" ''输出分页后的内容
end if
next
response.write chr(13)&"<hr>"
response.write "<p align=''center''>总共"&allline&"行 "&pagecount&"页 每页"&pageline&"行 "
for i=1 to pagecount
if thispage=i then
response.write i & " "
else
response.write "<a href='view.asp?action=view&newsclass="&class2&"&id="&id&"&page="&i&"'>"&i&"</a>"

end if
next %>
3 回复
#2
不惑2008-01-07 21:06
哈哈,把出错的行数和内容打出来啊.
这样才好分析啊.
#3
天涯听雨2008-01-07 22:20
很明显的错识:pagecount=int(allline\pageline)+1 ''计算总页数

出错在你求总页时。自己想想吧
#4
xmuer2008-01-07 23:02
看看这个~
[url]http://www.[/url]
1