Class AutoPaging
'*************************************************************
'目 的:自动将长文章分页输出
'属 性:Splitchar:分页搜索标志。以一维数组方式输入,默认array("br>","BR>","Br>","bR>")
' PagingString:要进行分页的字符串
' PagingSize:分页长度
' CurrentPage:当前输出页码
' DefaultRange:默认搜索分页标志范围
' StepRange:搜索步长
'方 法:getTotalPageCount():返回总分页数
' OutputString:输出当前分页内容
'*************************************************************
public Splitchar '分页搜索标志,数组
public PagingString '分页字符串
public PagingSize '页面最大长度
public CurrentPage '当前页码
public DefaultRange '默认起始范围
public StepRange '步长
private Truncate '2维数组m,n。m0=页码、m1=起始字符、m2=结束字符,n=总页数
private intStart '开始位置
private intLen '截取长度
private tmpStr
private Range '起始范围
private Sub Class_Initialize()
Splitchar=array("br>","BR>","Br>","bR>")
PagingSize = 2000
DefaultRange=1
StepRange = 1
intStart = 0
intEnd = 0
End Sub
public Function getTotalPageCount() '返回总页数
if len(PagingString) mod PagingSize > 0 then
getTotalPageCount = int(len(PagingString) / PagingSize) + 1
else
getTotalPageCount = len(PagingString) / PagingSize
end if
End Function
public Sub OutputString
redim Truncate(2,getTotalPageCount())
For tmpI = 0 to getTotalPageCount()
Truncate(0,tmpI)=tmpI
Next
For tmpI = 1 to ubound(Truncate,2)
if Truncate(0,tmpI) = 1 then
Truncate(1,tmpI) = 1
else
Truncate(1,tmpI)=Truncate(1,tmpI - 1) + Truncate(2,tmpI - 1)
end if
Range = DefaultRange
Do while Range PagingSize
tmpStr=right(mid(PagingString,Truncate(1,tmpI),PagingSize),Range)
For tmpInt=0 to ubound(Splitchar)
if instr(1,tmpStr,Splitchar(tmpInt)) > 0 then
Truncate(2,tmpI) = (PagingSize - (len(tmpStr) - instr(1,tmpStr,Splitchar(tmpInt)))) - 1
exit do
end if
Next