'storing the max value in the label(lbl_max) lbl_max.Text = max - 2 'storing the first value in the label(lbl_start) lbl_start.Text = 0
btn_next_Click
, do this code to increment the Label(lbl_start). And at the same time do it on prev_Click
for decreasing the value. Put this code, under the formula.
'passing the value of incVal into the label(lbl_start) lbl_start.Text = incVal
Private Sub btn_first_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_first.Click Try 'declaring the variable that count the 'number of records and it will be displayed in the datagridview Dim resultPerPage As Integer = 5 'declaring the variable for the first list 'of records that will display in the datagridview Dim startResult As Integer 'setting up the increment value which is the variable incVal to zero 'so that if you click the button, it return to original value incVal = 0 'formula of the list of records that will display in the datagridview startResult = incVal * resultPerPage 'passing the value of incVal into the label(lbl_start) lbl_start.Text = incVal con.Open() 'store the query with the limit to a string variable sql = "Select * from employees limit " & startResult & "," & resultPerPage & "" 'set a new spicific table in the database dt = New DataTable 'set your commands for holding the data. With cmd .Connection = con .CommandText =sql End With 'filling the table in the database da = New MySqlDataAdapter(sql, con) da.Fill(dt) 'getting the datasource that will display on the datagridview DataGridView1.DataSource = dt Catch ex As Exception End Try 'closing connection End Sub
Private Sub btn_last_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_last.Click Try 'declaring the variable that count the 'number of records and it will be displayed in the datagridview Dim resultPerPage As Integer = 5 'declaring the variable for the first list 'of records that will display in the datagridview Dim startResult As Integer 'setting up the increment value which is the 'variable incVal to the total rows 'in the table of the database incVal = max - 2 'formula of the list of records that will display in the datagridview startResult = incVal * resultPerPage 'passing the value of incVal into the label(lbl_start) lbl_start.Text = incVal con.Open() 'store the query with the limit to a string variable sql = "Select * from employees limit " & startResult & "," & resultPerPage & "" 'set a new spicific table in the database dt = New DataTable 'set your commands for holding the data. With cmd .Connection = con .CommandText = sql End With 'filling the table in the database da = New MySqlDataAdapter(sql, con) da.Fill(dt) 'getting the datasource that will display on the datagridview DataGridView1.DataSource = dt Catch ex As Exception End Try 'closing connection End Sub