Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
auto generated number
#1
i just wanna ask how to code an auto-numbering?

lets just say it start at 000000 and then if you add another the counter add by 1.. how can i do that? and how
to know where the counter stops? so that it doesnt back to 000000.
#2
Are you trying to add 1 to a variable? To a textbox text field? To a label?
My Blog | My Setup | My Videos | Have a wonderful day.
#3
im trying to add 1 in the variable.

let say.. the last added value is 10003 and then if
i add another entry the data or code should know that the last added value is 10003 so that when i added another entry the variable counter should be 10004..
#4
Well, first of all, you would need an integer variable to keep track of the number, so we can do this with something like this:
[code2=vbnet]Private Counter As Integer = 0[/code2]

Then, Every time we need to increment the variable, we can do so with:
[code2=vbnet]Counter += 1[/code2]

However, when we display the variable to the user, we would like it to be in the proper format. Since your number is 6 characters long, we pad left by 6 characters and fill any empty spots with 0s. Like so,
[code2=vbnet]Dim cString As String
cString = Counter.ToString.PadLeft(6, "0"c)[/code2]

Hopefully this helps.
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Auto-generating Drop Menus from User Input MadManMallard 2 11,816 09-17-2014, 09:41 AM
Last Post: brandonio21
  Random Number Generator manishshrestha60 4 14,603 10-30-2012, 05:43 PM
Last Post: brandonio21
  i need help on making a launcher with auto updating function jamietjeh 2 11,281 12-16-2011, 07:24 PM
Last Post: xolara

Forum Jump:


Users browsing this thread: 1 Guest(s)