Click here to Skip to main content
15,913,304 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
Let Say i have a form with label named(Number) then a textbox and Button(Save)

How to Increment a number in a textbox by 1?

I mean if i click the button save the number "1" in the textbox it will increment by 1 then if i don't save it and close the program the last number i left will be still remain (if it is not used for saving like what i have said earlier.)

Can someone give me a sample code for this in vb.net? Than You
Posted
Comments
Sergey Alexandrovich Kryukov 15-Oct-13 1:36am    
What's the problem? http://whathaveyoutried.com so far?
—SA

1 solution

You need to parse the text to some integer type. For example:
C#
int value;
if (int.TryParse(myTextBox.Text, out value))
   myTextBox.Text.Text = (++value).ToString();
else
   // do something when the text cannot be parsed as integer


—SA
 
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