tcadieux
04-11-2007, 08:38 PM
The below code works, however, the theory for the Last Button appears to be faulty for some reason becuase it's not rounding the number down to the correct LAST number.
Dim iStart, iOffset
iStart = Request("Start")
iOffset = Request("Offset")
if Not IsNumeric(iStart) or Len(iStart) = 0 then
iStart = 0
else
iStart = CInt(iStart)
end if
if Not IsNumeric(iOffset) or Len(iOffset) = 0 then
iOffset = 5
else
iOffset = Cint(iOffset)
end if
Dim iRows, iCols, iRowLoop, iColLoop, iStop
iRows = UBound(arrAllUnits, 2)
iCols = UBound(arrAllUnits, 1)
If iRows > (iOffset + iStart) Then
iStop = iOffset + iStart - 1
Else
iStop = iRows
End If
iNumberOfItems=iRows+1
Response.Write "<P>"
Response.Write ("<table width='100%' border='0'>")
Response.Write ("<tr>")
Response.Write ("<td width='25%'>")
if iStart > 0 then
'Show Prev link
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & iStart-iOffset & _
"&Offset=" & iOffset & NavigationVar & "' Class='SubHeadline'>Previous " & iOffset & "</A>")
end if
Response.Write ("</td>")
Response.Write ("<td width='50%' aLign='center'>")
' Show page numbers:
Z=iStart 'This is the current page you are one
C=iStart -5 'Current -5
B=C-5 'Current -10
A=B-5 'Current -15
IF iStart="0" THEN
A=""
B=""
C=""
END IF
IF iStart="5" THEN
A=""
B=""
END IF
IF iStart="10" THEN
A=""
END IF
N=iStart +5 'Current +5
O=N+5 'Current +10
P=O+5 'Current +15
IF N> iRows THEN
N=""
END IF
IF O> iRows THEN
O=""
END IF
IF P> iRows THEN
P=""
END IF
'IF Request.QueryString("keywords")="" THEN
IF iNumberOfItems >5 THEN
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & A &NavigationVar & "' Class='SubHeadline'>" & A & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & B &NavigationVar & "' Class='SubHeadline'>" & B & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & C &NavigationVar & "' Class='SubHeadline'>" & C & "</A>")
Response.Write (vbCrLf)
Response.Write ("<Font Color='Red' size='2'><U>" &Z& "</U></Font>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & N &NavigationVar & "' Class='SubHeadline'>" & N & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & O &NavigationVar & "' Class='SubHeadline'>" & O & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & P &NavigationVar & "' Class='SubHeadline'>" & P & "</A>")
Response.Write (vbCrLf)
END IF
Response.Write ("</td>")
Response.Write ("<td width='25%'><div align='right'>")
if iStop < iRows then
'Show Next link
Response.Write " <A HREF='"&SCRIPT_NAME&"?Start=" & iStart+iOffset & _
"&Offset=" & iOffset & NavigationVar & "' Class='SubHeadline'>Next " & iOffset & "</A>"
end if
Response.Write ("</div></td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td width='25%'>")
if iStart > 0 then
Response.Write ("<A href='"&SCRIPT_NAME&"?Start=0" &NavigationVar & "' Class='SubHeadline'>First</A></td>")
END IF
Response.Write ("<td width='50%' aLign='center'><P Class='UnitsDescription'>")
Response.Write (iNumberOfItems& " items<p/></td>")
Response.Write ("<td width='25%' aLign='Right'>")
' response.Write(iStop)
' response.Write(iRows)
' response.end
If iStop < iRows then
'Replace ther last Digit of iRows with a "0" so that the Paging will work
Response.Write ("<A href='"&SCRIPT_NAME&"?Start=")
Response.Write Left(iRows, Len(iRows) - 2) & Replace(iRows, Right(iRows,1), "0", Len(iRows) - 1)
Response.Write ("' Class='SubHeadline'>Last</A></td>")
End If
Response.Write ("</tr>")
Response.Write ("</table></p>")
'<--------------------- Paging ------------------------->
Dim iStart, iOffset
iStart = Request("Start")
iOffset = Request("Offset")
if Not IsNumeric(iStart) or Len(iStart) = 0 then
iStart = 0
else
iStart = CInt(iStart)
end if
if Not IsNumeric(iOffset) or Len(iOffset) = 0 then
iOffset = 5
else
iOffset = Cint(iOffset)
end if
Dim iRows, iCols, iRowLoop, iColLoop, iStop
iRows = UBound(arrAllUnits, 2)
iCols = UBound(arrAllUnits, 1)
If iRows > (iOffset + iStart) Then
iStop = iOffset + iStart - 1
Else
iStop = iRows
End If
iNumberOfItems=iRows+1
Response.Write "<P>"
Response.Write ("<table width='100%' border='0'>")
Response.Write ("<tr>")
Response.Write ("<td width='25%'>")
if iStart > 0 then
'Show Prev link
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & iStart-iOffset & _
"&Offset=" & iOffset & NavigationVar & "' Class='SubHeadline'>Previous " & iOffset & "</A>")
end if
Response.Write ("</td>")
Response.Write ("<td width='50%' aLign='center'>")
' Show page numbers:
Z=iStart 'This is the current page you are one
C=iStart -5 'Current -5
B=C-5 'Current -10
A=B-5 'Current -15
IF iStart="0" THEN
A=""
B=""
C=""
END IF
IF iStart="5" THEN
A=""
B=""
END IF
IF iStart="10" THEN
A=""
END IF
N=iStart +5 'Current +5
O=N+5 'Current +10
P=O+5 'Current +15
IF N> iRows THEN
N=""
END IF
IF O> iRows THEN
O=""
END IF
IF P> iRows THEN
P=""
END IF
'IF Request.QueryString("keywords")="" THEN
IF iNumberOfItems >5 THEN
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & A &NavigationVar & "' Class='SubHeadline'>" & A & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & B &NavigationVar & "' Class='SubHeadline'>" & B & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & C &NavigationVar & "' Class='SubHeadline'>" & C & "</A>")
Response.Write (vbCrLf)
Response.Write ("<Font Color='Red' size='2'><U>" &Z& "</U></Font>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & N &NavigationVar & "' Class='SubHeadline'>" & N & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & O &NavigationVar & "' Class='SubHeadline'>" & O & "</A>")
Response.Write (vbCrLf)
Response.Write ("<A HREF='"&SCRIPT_NAME&"?Start=" & P &NavigationVar & "' Class='SubHeadline'>" & P & "</A>")
Response.Write (vbCrLf)
END IF
Response.Write ("</td>")
Response.Write ("<td width='25%'><div align='right'>")
if iStop < iRows then
'Show Next link
Response.Write " <A HREF='"&SCRIPT_NAME&"?Start=" & iStart+iOffset & _
"&Offset=" & iOffset & NavigationVar & "' Class='SubHeadline'>Next " & iOffset & "</A>"
end if
Response.Write ("</div></td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td width='25%'>")
if iStart > 0 then
Response.Write ("<A href='"&SCRIPT_NAME&"?Start=0" &NavigationVar & "' Class='SubHeadline'>First</A></td>")
END IF
Response.Write ("<td width='50%' aLign='center'><P Class='UnitsDescription'>")
Response.Write (iNumberOfItems& " items<p/></td>")
Response.Write ("<td width='25%' aLign='Right'>")
' response.Write(iStop)
' response.Write(iRows)
' response.end
If iStop < iRows then
'Replace ther last Digit of iRows with a "0" so that the Paging will work
Response.Write ("<A href='"&SCRIPT_NAME&"?Start=")
Response.Write Left(iRows, Len(iRows) - 2) & Replace(iRows, Right(iRows,1), "0", Len(iRows) - 1)
Response.Write ("' Class='SubHeadline'>Last</A></td>")
End If
Response.Write ("</tr>")
Response.Write ("</table></p>")
'<--------------------- Paging ------------------------->