|
This is a practical project we just learned. ID is C followed by three digits. You can follow the following pattern to form the code you need, I hope it will help you. This table is arranged by ID number.
Dim custid, custidval As String
dt = DataSet11.Tables("CustomerTracking")'Assign the tables in the data set to dt
len = dt.Rows.Count-1'dt.row.count represents the number of rows in the dt table
dr = dt.Rows(len)'Give the last row of the dt table to dr
custid = dr("CustID")'Give the "CustID" in dr to custid
custidval = Mid(custid, 2, 3)'Go to the last three digits
ctr = CInt(custidval)'Convert to a numeric value and remove the leading 0
If ctr >= 1 And ctr <9 Then
ctr = ctr + 1
txtcustid.Text = "C00"&ctr
ElseIf ctr >= 9 And ctr <99 Then
ctr = ctr + 1
txtcustid.Text = "C0"&ctr
ElseIf ctr >= 99 And ctr <999 Then
ctr = ctr + 1
txtcustid.Text = "C"&ctr
End If |
|