• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2192
  • Last Modified:

Increase and decrease the text box value bases on button click event in vb.net?

Hello everyone,

I have a requirement where I have a text box, and a decrease button and increase button.

When the user enters any value, and clicks on increase or decrease button then the value should increase or decrease.

How can I do this in vb.net?

Any code sample Please?

Thank you!
  • 2
1 Solution
käµfm³d 👽Commented:
I would think you'd prefer a NumericUpDown control. However, to answer your question, you can simply try to cast the current text to a number and increment it.


Sub ButtonIncrement_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim value As Integer

    If Integer.TryParse(TextBox1.Text, value) Then
        TextBox1.Text = (value + 1).ToString()
    End If
End Sub

Open in new window

Obviously, the decrement would be a subtraction instead of an addition  = )
developer2012Author Commented:
Thanks I will try it .
developer2012Author Commented:
Thanks it worked.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now