Three digits

Hi there,
I need some help with a format
I have a textfield with the result of a double, and the format is “00,000000” I would like to show only three digits "00,000) I have tried with format, validation mask, max. characters allowed, single…

Thnaks in advance

Var d As Double = 789.1234567

System.DebugLog d.ToString(Locale.Current,"0.000")
1 Like

Thanks but this doesn’t work to me

In the LostFocus event of that field, put:

Me.Text = Me.Text.ToDouble.ToString(Locale.Current,"0.000")

Don’t work, I have t ried when lost focus, when change, open…
I attached a picture.
Textfields are readonly

So format the data when you put it in the field.

Can you show the code that you are using to fill those fields?
Can you share a sample using dropbox that we can see the code?

If Locale.Current is a non-English country, as the screen shot would suggest, wouldn’t the decimal separator in the format argument have to be “,” and not “.”?

Me.Text = Me.Text.ToDouble.ToString(Locale.Current,"0,000")

make sure you have the textfield mask and format set empty.
then use what @Greg_O_Lone suggested:

Me.Text = Me.Text.ToDouble.ToString(Locale.Current,"0.000")

Do you have three (3) default PushButtons in that window ?

Nuevo, Modificar, Borrar ?

if your source is double you need to convert it to string for the textfield.
user can still input anything.
from the textfield you would convert the string back to double.
the type currency have a fix amount of decimal places.

I convert the double totext, but I give a try tostring and It doesn’t operate. I will try with currency although, I’ll have to change a half of app.

Thank you so much everyone, but it doesn’t work.
Now I have this format ###.###.### that is correct, but I wouldn’t like to see the last three digits.

No, it isn’t.

No. The format string is internationally coded – you need to address decimal separator with “.” and 1000’s group separators with “,” universally.

1 Like

To add to Markus’ reply:
A format string “###.###.###” is wrong. Dot is the decimal separator, so the format string does not make real sense. Something like “###,###,###.000” would format a number to use 1000s separators and always three digits after the comma.
But as Albertos said: Please show the code you use to fill your text fields.

1 Like

What you need to understand is that characters in a mask have special meaning and therefore differ from what is shown.

Eg the decimalSeparator is the comma in Germany and the dot in the US and might be something else in other countries, but in a formatting mask it is always the dot.

1 Like

Forget the Format in the inspector.

Me.Value = Format (Val (Me.Value.Replace (",",".")), “-#.000”)

Oooh, you are going to have soooo much fun with international numbers … :smiling_imp:

1 Like

Oke Markus, that is correct when the amount > 999,99