Increase and decrease the text box value bases on button click event in

Posted on 2012-08-17
Last Modified: 2012-08-17
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

Any code sample Please?

Thank you!
Question by:developer2012
    LVL 74

    Accepted Solution

    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  = )

    Author Comment

    Thanks I will try it .

    Author Comment

    Thanks it worked.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now