Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Day Experts!,

i would like to ask if anyone can help me with my code. i want to display a auto-generating alphanumeric numbers like this:

OR06161400001

which is in my code is something like this:

VB
Dim con As New SqlConnection(ConnectString())
       Dim cd As New SqlCommand
       Dim lrd As SqlDataReader
       Try
           con.Open()
           cd.Connection = con
           cd.CommandText = "SELECT count(ornumber) as co FROM BlueRoomTransactions"
           lrd = cd.ExecuteReader()
           While lrd.Read()
               ornum = Convert.ToString(lrd("co"))
           End While
       Catch ex As Exception
       Finally
           con.Close()
       End Try

       ornum = ornum + 1

txtORNumber.Text = "OR" + Date.Today.ToString("MMddyy") + "" + ornum.ToString.PadLeft(5, "0")

what i want is to display the first alphabet "A" after the date.then if it reach 100,Letter "A" becomes "B".

i tried using this code but all i get is the last alphabet.

VB
Dim iChar As Integer

           For iChar = Asc("a") To Asc("z")

               MsgBox(Chr(iChar))

           Next iChar



Thanks.
Posted

1 solution

Looks like you want to generate the id's yourself which is never a good idea. There is no need to make the id's more complex then they are. A prefix is fine when you want people being able to communicate id's in context, adding the prefix to make it clear to what table it belongs. But even then you could just give them an entity. This would make it even more easier and understandable for all.

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900