0

Possible Duplicate:
auto generating numbers

how to increment a numbers in textbox control in c# windows app.samples like s001 and should be increment always when i come to form it should be like s002.where should i have to write a code either in textbox or forml_load event.

Community
  • 1
  • 1
vamshi
  • 199
  • 2
  • 3
  • 5
  • 1
    What does it mean "when I come to form"? Is it applied if you minimize and restore the form? – vortexwolf Feb 04 '11 at 12:33
  • 3
    **[Not you again](http://stackoverflow.com/questions/4897658/auto-generating-numbers)...** You just asked this question. What was wrong with the answers given there? – Cody Gray - on strike Feb 04 '11 at 12:33

2 Answers2

2

You can use following code at an appropriate place in your form to increment TextBox's value by one:

TextBox1.Text = String.Format("{0:000}", Int32.Parse(TextBox1.Text) + 1);
decyclone
  • 30,394
  • 6
  • 63
  • 80
0

You must write the code in Form_load event and the number must be publicly define...

each time to load the form the textbox text must be loaded with new value.

Bhavik Goyal
  • 2,786
  • 6
  • 23
  • 42