Results 1 to 4 of 4

Thread: Increment and decrement in a NumericUpDown button

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2010
    Posts
    87

    Increment and decrement in a NumericUpDown button

    I would like a program that will use a NumericUpDown button:

    -when the up arrow is clicked, the number in the NumericUpDown box will increment by 2
    -when the down arrow is clicked, the number in the NumericUpDown box will decrement by -2

    I got the button inserted and double clicked on it to get the NumericUpDown1_ValueChanged but am stuck there. I looked thru the MSDN site but no help there. Does anyone have any suggestions?

  2. #2
    Addicted Member
    Join Date
    Mar 2010
    Posts
    231

    Re: Increment and decrement in a NumericUpDown button

    Can you explain in more details ?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2010
    Posts
    87

    Re: Increment and decrement in a NumericUpDown button

    When you click the up arrow button it only increments by "+1". Also when you click the down arrow button it only decrements by "-1". I want to increment by a higher number say 2,5 or 100. Also can it be done in a separate subroutine then it could activate the main subroutine with a call after each increment.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Increment and decrement in a NumericUpDown button

    Quote Originally Posted by Philosophaie View Post
    I looked thru the MSDN site but no help there. Does anyone have any suggestions?
    It really concerns me when I see posts like this because it makes me wonder where you actually looked. You apparently didn't look in what I would consider to be the obvious place, i.e. the documentation for the NumericUpDown class itself.

    http://msdn.microsoft.com/en-us/libr...VS.100%29.aspx

    Not too far down the list of members is the Increment property, described thusly:
    Gets or sets the value to increment or decrement the spin box (also known as an up-down control) when the up or down buttons are clicked.
    That is obviously what you want so, as I said, your claim that MSDN was no help is false. You just didn't look in the right place. You should always look in the obvious places first, and the documentation for the type or member you're using is the most obvious place.

    Don't assume that something is difficult and complex. Assume that it's simple and look for a simple solution first. Only look for difficult and complex solutions if no simple option presents itself.

    Speaking of simple solutions and obvious places, did you not think to look in the Properties window? The Increment property is there, described thusly:
    Indicates the amount to increment or decrement on each button click.
    Again, quite obviously what you want, but you won't see if you don't look.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width