im doing small vbproject that must auto generate id using the current date format in vb.net-(VISUAL STUDIO 2012) with Ms access database. When the button1 click the autonumber should be displayed in text. And when it save, it should be saved in the database access. The id number should be like this eg: "1125130000, 11251300001" and so on.
please someone kindly help me as soon as possible. please.
Thanks in advance.
Well you can extract the date,month and year using Date functions and then apply following algorithm.
1) Extract month (suppose you got 11) then,
2) Extract date (suppose you got 9 ) then,
id=id*100 + date (id=1100 + 9=1109)
3) Extract year (suppose you got 13) then,
id=id*100 + year (id=110900 + 13=110913)
4) Then as i see you wish to have 5 digits space so do
5) Now you can increment the user on button click.
Is a hard 5 digit sequence required? If all you need is something that's larger than the previous ID and smaller than the next, you can use the custom date time formatting to get a high enough resolution that practically guarantees uniqueness:
' Timestamp down to the millisecond
Id = DateTime.Now.ToString("yyMMddHHmmssFFF")