<%
"以下部分是验证提交的page是否为合法的参数
"这部分最好判断一下提交的参数是否为数值字符
dim page
page=Trim(request("page"))
If page="" Then 
page=1
Elseif CInt(page)<=0 then
page=1
else
page=CInt(page)
End If"进行查询,取出要显示的记录
dim rs,sql,str
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from a1"
rs.Open sql,conn,1,3
if Not rs.eof Then
str=rs("a1")
End If
rs.close
Set rs=nothing"把出取来的记录放入数组
dim strtmp
strtmp=Split((str),"<br>")"取出要显示的记录,同时得到页数
Dim n,tmp,i,j,tt
n=500
i=0
j=0
Do While i<=ubound(strtmp)
tmp=strtmp(i)
tt=true
Do While tt
If i>=ubound(strtmp) then
tt=false
j=j+1
elseif Len(tmp)>=n Then
tt=false
j=j+1
ElseIf Len(tmp)+Len(strtmp(i+1))>=n Then
tt=false
j=j+1
Else
tmp=tmp+"<br>"+strtmp(i+1)
i=i+1
End If
Loop
if page=j then str=tmp+"<br>"
i=i+1
Loop
"判断传送的参数是否越界,如果越界,则取得最后一页的内容
if page>j then
str=tmp
end if"显示分页内容
"注意传递的参数,这里只传递了page,如果有其它参数要一起传递的,否则分页后不显示了
response.write "分页——>"
For n=1 To j
if n=page then
response.write "&nbsp;"&n&"&nbsp;"
else
response.write "[<a href=index.asp?page="&n&">"&n&"</a>]"
end if
Next
response.write "<br><br>""显示要分取出要显示的这部分内容
response.write str
%>