Long content automatic paging function developed by VB.NET

xiaoxiao2021-03-06  81

You can automatically paginize your length.

With the automatic paging feature, just tell the computer that the number of words per page per page can be.

The following attachments, convenient, convenient, easy to study:

Public Class Webform1

Inherits System.Web.ui.page

Protected Withevents Label1 As System.Web.ui.WebControls.label

Protected Withevents Label2 As System.Web.ui.WebControls.Label

Protected Withevents label3 as system.web.ui.webcontrols.label

Protected Withevents Label4 as System.Web.ui.WebControls.Label

#Region "The code" of the web form designer "

'This call is required for the web form designer.

private subinitializecomponent ()

End Sub

Private sub page_init (byval sender as system.object, byval e as system.eventargs) Handles mybase.init

'Codegen: This method call is necessary for the web form designer

'Don't modify it using the code editor.

InitializeComponent ()

End Sub

#End region

Private Sub Page_Load (Byvale AS System.Object, Byval E AS System.Eventargs) Handles MyBase.Load

'Place the user code of the initialization page here

Pages ()

End Sub

'Long content paging

SUB Pages ()

Dim i, Start, Stops, T, Stat, Statt, PP, Pagecount, PageSize, ArticleID AS Integer

Dim Pa, Articles, Articles, ContentText, HTML AS String

ContentText = "

AAAAAA

bbbbbbbbbb

cccccccccccccccccccc

'Variable initial value

STAT = 0

STATT = 0

START = 0 'Start the string position of the query, initial 0

Stops = 0

PageSize = 2 'Defines at least the number of strings per page

PageCount = 0

'Get the current number of pages

PA = Request.Params ("Page")

IF (PA = "" or isdbnull (pa)) THEN

PA = "1"

END IF

PP = Convert.TOINT32 (PA)

'Get content

Articletxt = ContentText

'Determine whether the content length of the page is greater than the number of strings in each page defined

If (Articlesize) THEN 'If it is greater than the number of strings, we can display

T = articles taxt.length / pagesize 'Get a rough total page

'Recycling according to the current page number

For i = 0 to t 'If the query starts to the range of the query exceeds the length of the entire content, then don't look for breakpoints (point points); contrary to find

IF (Start Pagesize

Stat = articles taxt.indexof ("", start pagesize) 'Find the location of the

'If you can't find it

'IF (stat <= 0) THEN

'stat = articles taxt.indexof ("", start pagesize) Find the location of the page point; here you can set your own judgment

'End if

END IF

'Response.write ("'" & stat & "'")

IF (stat <= 0) THEN

'If you can't find a page point, you can't paid, you don't need to do other labor; otherwise,

'articles kettlext = articles et et 结果 结果 结果 结果 变 导 导 变 的

'Label1.Text = ArticleText & Stat

'Exit Sub

Else

The location of the stops = stat 'page point is also the end point of this page.

IF (start pagesize> = articles "If the start position to the range of the query exceeds the length of the entire content, then the end point of this page is the end point of the content.

Stops = articles ketxt.length

END IF

IF (pp = i 1) Then 'If it is current, then output the content of the current page

ArticleterText = articles ketxt.substring (start, stops - start) 'Take the start position of the content to the end position of this string output

Label1.text = articles

END IF

Start = stat 'uses the end position as the starting position of the next page

PageCount = PageCount 1 'Get the total number of actual pages

'Response.write ("-" & PageCount & ")

END IF

NEXT

END IF

'Pipeline section (here is much simpler)

'Define paging code variables

IF (PageCount> 1) THEN 'When the number of pages is greater than 1, we display the number of pages.

'Response.Write (PP)

IF (PP - 1> 0) THEN 'Display Previous, convenient to browse

HTML = " [Previous]

Else

IF PP = 1 THEN

HTML = "[ Previous ]"

Else

HTML = "

END IF

For i = 1 to PageCount

If (i = pp) Then 'If it is a current page, bold display

HTML = " [" & I & "] "

Else

HTML = " "

END IF

NEXT

IF (PP 1> PageCount) THEN 'Show next page, convenient to browse

IF pp = PageCount Then

HTML = "[ Next Page ]"

Else

HTML = " [Next]

END IF

Else

HTML = " [Next Page]

END IF

END IF

Label2.text = HTML

End Sub

END CLASS

转载请注明原文地址:https://www.9cbs.com/read-81149.html

New Post(0)