Thursday, December 17, 2009

Dynamic page number

Found this code snippet which is quite useful if you're allowing dynamic configurable page length:

intOldPageLength = GetPageLengthValue()

' if there is a new page length value
If intOldPageLength <> m_intPageLength Then

' adjust the page number to compensate
intItemCount = ((m_intPage - 1) * intOldPageLength) + 1
m_intPage = intItemCount \ m_intPageLength
If intItemCount - (m_intPage * m_intPageLength) > 0 Then
m_intPage = m_intPage + 1
End If

End If

Your Ad Here