ASP分页时计算页面总数的几种算法小结
编程学习 2021-07-05 10:58www.dzhlxh.cn编程入门
今天在用ASP做项目时用到了分页,其中计算页面总数时让我折腾了半天,当设置每页显示的记录数不同时,计算页面总数总是有误,于是在网上查看别人的算法,现拿来分享相关代码
狼蚁网站SEO优化是我从网上找到三种ASP分页时计算页面总数的方法,此方法仅为分页时计算页面总数,并非整个分页代码:
方法一
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
If HTMer_RecordCount Mod HTMer_PageSize=0 Then
HTMer_PageCount=Int(HTMer_RecordCount/HTMer_PageSize)
Else
HTMer_PageCount=Int(HTMer_RecordCount/HTMer_PageSize)+1
End If
方法二
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
HTMer_PageCount=Int(HTMer_RecordCount/HTMer_PageSize*-1)*-1
方法三
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
HTMer_PageCount=Abs(Int(-(HTMer_RecordCount/HTMer_PageSize)))
方法四
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
HTMer_PageCount=Fix(HTMer_RecordCount/HTMer_PageSize)-CInt(CBool(HTMer_RecordCount Mod HTMer_PageSize))
方法一
代码如下:
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
If HTMer_RecordCount Mod HTMer_PageSize=0 Then
HTMer_PageCount=Int(HTMer_RecordCount/HTMer_PageSize)
Else
HTMer_PageCount=Int(HTMer_RecordCount/HTMer_PageSize)+1
End If
方法二
代码如下:
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
HTMer_PageCount=Int(HTMer_RecordCount/HTMer_PageSize*-1)*-1
方法三
代码如下:
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
HTMer_PageCount=Abs(Int(-(HTMer_RecordCount/HTMer_PageSize)))
方法四
代码如下:
' HTMer_RecordCount为要计算的页面总数
' HTMer_RecordCount为记录集数
' HTMer_PageSize为每页记录数
HTMer_PageCount=Fix(HTMer_RecordCount/HTMer_PageSize)-CInt(CBool(HTMer_RecordCount Mod HTMer_PageSize))