Textfield Mask

Hi, How to use mask for number like calculator?
For example, Mask : 999,999,999
If I input number 1234567 and result is 123,456,7 not 1,234,567

Thanks

yup… Mask is ALL screwed up it seems :slight_smile:

Not screwed up. It just fills left to right. There’s no way for the field to know what the intent of the text is.

Well a mask is numeric most of the times, perhaps a flag IsNumeric could center numbers around the decimal separator instead as a feature?

[quote=418219:@Dede Gardea]Hi, How to use mask for number like calculator?
For example, Mask : 999,999,999
If I input number 1234567 and result is 123,456,7 not 1,234,567

Thanks[/quote]

Try “999,999,999.”

You need to look at the mask characters in the language reference for the Mask property. Use a period as a decimal placeholder, and it will format around the decimal. The actual character displayed is based on the user’s international settings; for USA that is typically a period. Likewise you can add commas as thousands separators, but again the actual character displayed is based on the user’s settings.

See also the Format property; they work together. The Mask affecting input and the Format affecting output. But consider also that Mask can be helpful for “numeric” entries with other formatting where you DO want them to fill left to right. For example, phone numbers or USA Social Security Numbers.

Use Mask and Format together, and they can be helpful with zero code on your end for keystroke handling.

Result is still the same 123,456,7

I didn’t expect that

Mask: “999,999,999”

produce different results depending on the defaut settings for your country (at the OS level).

Here, in France, 123456789 produce “123 456 789” since the thousands separator is a space (not a comma like in the US).

Xojo 2015r1.

In Xojo 2018r4, use this mask “999\,999\,999” to get “123,456,789” to bypass the OS default settings (at your risk).

I just used \. to get anumber with decimal dot ON PURPOSE (and no risks).