其中使用到一個分頁類CPaging
複製代碼 代碼如下:Class CPaging
Public RS ' RecordSet對象
Public Mark ' 指標標籤
Private sSize ' 每頁顯示數
Private sTotal ' 總記錄數
Private sPage ' 當前頁碼
Private sCount ' 總頁碼
Private Sub Class_Initialize
sSize = 20
sPage = 1
sCount = 1
End Sub
Private Sub Class_Terminate
Closeobj RS
End Sub
'每頁顯示數
Property Let Size(Value)
sSize = Value
End Property
Property Get Size
Size = sSize
End Property
'當前頁碼
Property Let Page(Value)
If Not IsNumeric(Value) Then
sPage = 1
Else
sPage = Value
End If
End Property
Property Get Page
If (sPage - 1) * sSize > sTotal Then
If sTotal Mod sSize = 0 Then
Page = Total \ sSize
Else
Page = Total \ sSize +1
End If
ElseIf sPage < 1 Then
Page = 1
Else
Page = sPage
End If
End Property
'總頁碼
Property Get Count
If sTotal Mod sSize = 0 Then
Count = sTotal \ sSize
Else
Count = sTotal \ sSize + 1
End If
End Property
'總記錄數
Property Get Total()
Total = sTotal
End Property
Public Function Open(Byval SQLString)
Try DB.Openquery(RS,SQLString)
sTotal = RS.RecordCount
End Function
End Class
以下是調用頁 複製代碼 代碼如下:Dim Products
Set Products = New CPaging
With Products
.Size = 15 '每頁顯示數
.Page = PageNum '當前頁
End With
Try Products.Open(ListSQL)
If Products.RS.Bof and Products.RS.Eof then
Response.Write("<TR><TD colspan=8>尋找無記錄</TD></TR>")
Else
Dim i
i = 0
Products.RS.Move (Products.Page - 1) * Products.Size
Do While Not Products.RS.Eof
Response.Write("<TR onmouseup=MouseUp(this); onmousedown=MouseDown(this); onmouseover=MouseOver(this); onclick=Click(this); onmouseout=MouseOut(this);>"&vbCrLf)
Response.Write("<TD align=middle nowrap>" & Products.RS("ProductsClassName") & "</TD>"&vbCrLf)
Response.Write("<TD align=left nowrap>" & Products.RS("ProductsName") & " </TD>"&vbCrLf)
Response.Write("</TR>"&vbCrLf)
i=i+1
If i >= Products.Size Then Exit Do
Products.RS.MoveNext
Loop
End If
當看到第8行的時候,似乎窺到了.net的影子--命名空間?