Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jun 2001
    New York, New York, Lebanon
    Thanked 1 Time in 1 Post

    2 ways to increment a numeic UpDown

    Hello Loungers

    OK am I crazy or what, no this is not my question my question is...

    Is there an easy way to have multiple ways to have a numeric UpDown increment by 1 and 10?

    Say if you click inside the numeric UpDown it goes by 10, but if you use the Up and down arrows then it goes by 1?

    I am hoping this has the same behavoir as the scroll bar.

    Thanks for any help.

    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Manning, South Carolina
    Thanked 1,454 Times in 1,323 Posts

    I can't find a way to do this exactly as you want but I have found a work around. It can be done if the control key is pressed while clicking via the SpinDown & SpinUp events. This also requires Windows API code courtesy of Chip Pearson's site. I've attached an Excel workbook example. Of course, I assumed you were talking about a Spinbutton and were working in Office since you didn't specify the language or environment.

    Option Explicit
    'Note Requires code from Chip Pearson's site see the WindowsAPI module.
    ' If the Control Key is pressed the following routines will increase/decrease
    ' the value in the attached cell by 10. The code increments/decrements by 9
    ' because the normal operation of the button takes care of the other 1 of the
    ' increment/decrement
    Private Sub SpinButton1_SpinUp()
       If IsControlKeyDown() Then
         SpinButton1.Value = SpinButton1.Value + 9
       End If
    End Sub
    Private Sub SpinButton1_SpinDown()
       If IsControlKeyDown() Then
         SpinButton1.Value = SpinButton1.Value - 9
       End If
    End Sub
    FYI: I almost forgot that I discovered while testing this that the Up Arrow & Right Arrow Reduce number and the Down Arrow & Left Arrow Increase number. So you can control the spinner, once it is selected, with the KBD.
    Attached Files Attached Files
    Last edited by RetiredGeek; 2012-03-04 at 11:11.
    May the Forces of good computing be with you!


    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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