Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There is table with information about cars and its owners and some other documents, all this information will be writen on the special list (one row for one car and its owner), I need a unique serial number for each row in the table. Two letters and 6 numbers is a standart for this documents. Valid is a separate generator for letters and numbers, in diferent fields. Code should be such that it could be written to a button in MS Access, it is desirable VBA :confused:
Posted
Updated 28-Nov-10 9:32am
v2

well , i access i can't help
but if you want some code in c# that can help you or may bring close the solution to you that is it :

private static string GenerateData(int lettersCount, int numsCount)
       {
           string str = string.Empty;
           Random ran = new Random();
           for (int i = 0; i < lettersCount; i++)
           {
               str += ((char)ran.Next(65, 91)).ToString();
           }
           for (int i = 0; i < numsCount; i++)
           {
               str += ran.Next(0, 9).ToString();
           }
           return str;
       }


i hope i can help more
 
Share this answer
 
If you try to use a random generator, sooner or later you will get a duplicate. If you want to use a random sequence, then you'll need to check for dups each time.

I would use an incrementing system and save the last used in either a config file or Access table. When you need a new number, just increment the last one and save it back for next time. (That's basically how the AUTO INCREMENT works, but it only uses numbers, not letters.)

It's not clear whether the letters or numbers actually need to mean anything, but that's something you'll have to decide.
 
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