NumUpdDown buttons

skipper

Member
Licensed User
Hello all

is there any way to distinguish between Up and Down buttons in a NumUpDown control? I would like to intercept the DOWN button at value=0 to set value=Maximum and count backward (or UP button at Value=Maximum to set Value=0 and count forward.

In case eg. Maximum is 10 and the value to be set is 8, it would be faster to count backward 0,10,9,8 than count forward 0,1,2,3,4,5,6,7,8....


Many thanks

Mimmo
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this code:
B4X:
Sub Globals
    ignoreEvent = False
End Sub

Sub App_Start
    Form1.Show
    Num1.Minimum = -1
    num1.Maximum = 11
End Sub

Sub Num1_ValueChanged
    If ignoreEvent Then Return
    If num1.Value = num1.Minimum Then
        ignoreEvent = True
        num1.Value = num1.Maximum-1
    Else If num1.Value = num1.Maximum
        ignoreEvent = True
        num1.Value = num1.Minimum+1
    End If
    ignoreEvent = False
End Sub
 
Top