ValidationMask and slider

Hello,
I’m new in Xojo an have some Problems:

  1. I like to get a decimal number with at most 2 digits before and to decimals behind the comma as Input of a text field. I did this by using
    TextField1.ValidationMask = “99\,99”
    The Documentation says:“You can set the ValidationMask property in the Properties pane.” But if I try to add a property to the text field I get to the Window
    properties and it doesn’t work. Now I placed the code in the window-open-event handler. It works, but is this the right place?

2.) Next to the text field I placed a slider to quickly change the value of the textField. The slider varies from 0 to 9999, but in the textfield I like to see the values as 0…99,99.
I can’t find an easy way to insert a comma on 3rd place in a string. Or do I have to convert to a double and divide by 100 and then convert to a string? The Format-Option didn’t work to the slider.value.

I appreciate any help :wink:

textfield1.text=format(slider1.value/100,"#,###.##")

is that what you wanted?

Wow, Problem 2 is solved. I am very impressed! I’ve been trying to do this for hours. Thanks a lot!
But I don’t understand, why does “#,###.##” work? Why not “##,##”?

or “99.99”

LOL… guessing you are NOT in the US… the format statement uses “,” for thousands and “.” for decimal even if your locale is the opposite of that

[quote]
Although the special formatting characters are U.S. characters, the actual characters that will appear are based on the current operating system settings. For example, Windows uses the settings in the user’s Regional and Language Options Control Panel. Formatting characters are specified in similar ways on other operating systems.[/quote]

Yes, I’m from Germany :slight_smile:
If the slider has the Value 0 then “0,” appears in the text field. Is there a possibility to get rid of the comma if the 0 is standing alone?

the format will not insert a thousand separtor if the value is less than 1000,

the format should be 99 [COMMA] 999 [PERIOD] 00

regardless if you use [PERIOD] as a separtor, for this you must us the US characters

Hi @Hardy Koch

Maybe you may consider my AXumValidatedTF class to see if it fits your problem. You can download and try it as long as you want!