Sub ShowPageBar(TotalPage,CurPage,strUrl)
''参数TotalPage:全部页数
''参数CurPage:以后页数
''参数strUrl:翻页利用的毗连地址
DIM strPage
CurPage=GetValidPageNO(TotalPage,CurPage)
Response.Write "<TABLE WIDTH=''100%''>"
Response.Write "<TR><td width=''100%'' align=''right''>"
Response.Write "页数:" & CurPage & "/" & TotalPage & " "
IF InSTR(strUrl,"?")=0 THEN
strPage="?Page="
ELSE
strPage="&Page="
END IF
IF Curpage>1 THEN
Response.Write "<a href=" & strUrl &strPage&"1>第一页</a>|"
ELSE
Response.Write "第一页|"
END IF
IF CurPage>=2 THEN
Response.Write "<a href=" & strUrl & strPage &CurPage-1&">上一页</a>|"
ELSE
Response.Write "上一页|"
END IF
IF cInt(CurPage)<cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage &CurPage+1&">下一页</a>|"
ELSE
Response.Write "下一页|"
END IF
IF cInt(CurPage) <>cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage & TotalPage&">最初一页</a>"
ELSE
Response.Write "最初一页"
END IF
Response.Write "</TD></tr></table>"
END SUB
Function GetValidPageNo(PageCount,CurPage)
Dim iPage
iPage=CurPage
IF cInt(CurPage)<1 THEN
iPage= 1
END IF
IF cInt(iPage) > cInt(PageCount) THEN
iPage= PageCount
END IF
GetValidPageNo=iPage
END Function
%>
上面是利用这个函数的例子,文件称号是showinfo.asp
<!--#include Virtual="page.inc"-->
<%
SET objConn=Server.CreateObject("ADODB.CONNECTION")
SET objRst=Server.CreateObject("ADODB.RECORDSET")
objConn.Open APPLICATION("dsn")
strSQL="SELECT * FROM ********"
''这里是你要利用的查询
objRst.Open strSQL,objConn,adOpenStatic
’翻开数据纪录
objRst.PageSize=50
’设置单页的数据纪录数
iPageCount=objRst.PageCount
’界说了一个页码数目的变量
If Len(Request.QueryString("Page"))=0 Then
CurPage=1
Else
CurPage=CInt(Request.Querystring("Page"))
End If
’失掉以后的页码
objRst.AbsolutePage=CurPage
’设置纪录集中确当前页