adding number in text box

Steven Low

Active member
Joined
Apr 14, 2005
Messages
42
Programming Experience
1-3
Hi guys I am a newbe to vb.net

and my problem is that. by a click of a button i want to add 3 to textbox1. soo the number is increasing each time. Can someone show me an example of how this would be done please:confused:
 
Place a button on your form and name it Button1

then inside the click event of the Button put this

VB.NET:
[SIZE=2]TextBox1.Text = Str(Val(TextBox1.Text) + 3)

it takes the value of what is inside the text string of Textbox1 and adds 3 to it then converts it back to a string and places it into the text field of the Textbox.
[/SIZE]
 
i would personally stay away from the Val() function and use:
TextBox1.Text = (CInt(TextBox1.Text) + 3).ToString()
 
Back
Top