Is there any way to make the slider pointer snap to certain points along the slider?
For example, if I have a slider that goes from -100 to 100, how could I make que sliper pointer snap to the 0 (zero) whenever the slider pointer approaches 0 (zero)?
there is also a property linestep in designer.
Me.Value = (Me.Value \ 25) * 25
System.DebugLog Me.Value.ToString
Nice, but that always jumps to the left (lower) value, not the closest one. Try
Me.Value = ( (Me.Value + 10) \ 20) * 20
Basically
Me.Value = ( (Me.Value + HalfStep) \ Step) * Step
2 Likes
I managed to solve this with:
Var value,remapped As Int32
value = Me.Value
if Abs(value)<5 then
value = 0
remapped = 0
end if
if Abs(value)>= 5 then
remapped = Sgn(value)*(Abs(value)-5)
end if
me.Value = value
output.Text=Str(remapped)
And
Sgn(x As Variant) As Int32
if x = 0 then
return 0
end if
return Abs(x)/x
Oh, and I had to set the slider to range from -105 to 105, instead of -100 to 100.