Example : How to Auto Increment the Serial number value in a text box
(Put database connectivity code here first and write the code either at form load event or other proper event)

Sub autoincrement()
   Dim x As String = ""
   Dim p1,p2 As Integer
   p1 = 0
   cn.Open()
   cm.CommandText = "select refno from sale"
   rdr = cm.ExecuteReader()
      While (rdr.Read())
         x = rdr("refno").ToString
         p2 = Val(x)
         If p2 > p1 Then
            p1 = p2
         End If
      End While
   cn.Close()
   Textbox1.Text = p1 + 1
End Sub

 337 total views,  1 views today

Categories: VB .Net

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.