Reputation: 129
I'm stuck on this exercise that asks me to create a text box and a button. Each time the button is pressed it is supposed to add 1 to the text box. Anyone know how to approach this?
Upvotes: 0
Views: 11053
Reputation: 17010
Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim i as Integer = int.Parse(TextBox1.Text)
i += 1
TextBox1.Text = i.ToString()
End Sub
You will also want to protect any attempt to key press in the textbox or set it where Enabled=true.
Upvotes: 3
Reputation: 121294
Upvotes: 1