NumUpDown control

davelew1s

Active Member
Licensed User
Longtime User
Hi!
Can the NumUpDown control be used to increment and display numbers with a decimal point? I've had a play but nothing is obvious ...any ideas?
Dave Lewis.
 

Cableguy

Expert
Licensed User
Longtime User
Staright answer....NO

BUT you can use a combination of num control to create a decimal number...
like one to the hole number, one to 1/10ths and one th the 1/100... then combine the results

a=num1.value &","& num2.value & num3.value
suposing that the min is set to 0 and max to 9

If num1 = 5 and num2=4 and num3 = 2
a=5,42
 

Stellaferox

Active Member
Licensed User
See also the code in this example, not yet finished under the control UNITS.
Marc
 

Attachments

  • $PRNG.sbp
    9.5 KB · Views: 256

RandomCoder

Well-Known Member
Licensed User
Longtime User
Here's a simple solution, I offered to someone in the old forum who wanted to increment in Tens...

Just overlay a TextBox over the NumUpDown control, now you can display in whatever units you want, you could even add a symbol if needed.

Attached is an example that counts in 0.1 increments, bet you can't spot any difference in operation to a normal NumUpDown control :cool:

Regards,
RandomCoder
 

Attachments

  • Decimal NumUpDown.sbp
    461 bytes · Views: 284

agraham

Expert
Licensed User
Longtime User
bet you can't spot any difference in operation to a normal NumUpDown control
Well the text is grey and doesn't match other controls' text because the Textbox needs to be disabled and this automatically greys the text.:(

To REALLY make it look like a normal UpDown control leave the Textbox enabled and use a GotFocus event procedure to prevent user entry.:cool:
B4X:
Sub TextBox1_GotFocus
    Num1.Focus
End Sub

EDIT: Erel, if you read this, why do I get two GotFocus events in this situation? Without the Num1.Focus I get the single event I expect, if I call the .Focus method on any other control I get called twice!
 
Last edited:

davelew1s

Active Member
Licensed User
Longtime User
Hi!
Thanks for the replies, Randomcoder your solution works find for me the fact that it's greyed out is a bonus.
Dave.
 
Top