The correct way to format a number
-
Hi everyone, I was wondering, what would be the correct way of formatting a number, based on regional settings. For example:
Dim value as double = 123456.78 Label1.Text = value
The label would show:123456.78
I need it to show:123,456.78
if I'm in the UK123.456,78
if I'm in Europe I'm sure its a simple Format problem. Just cant remember. Any ideas Mark -
Hi everyone, I was wondering, what would be the correct way of formatting a number, based on regional settings. For example:
Dim value as double = 123456.78 Label1.Text = value
The label would show:123456.78
I need it to show:123,456.78
if I'm in the UK123.456,78
if I'm in Europe I'm sure its a simple Format problem. Just cant remember. Any ideas MarkUse the format string "N2" to format the number. It will give you the correct format for the current regional settings.
Mark06 wrote:
123,456.78 if I'm in the UK 123.456,78 if I'm in Europe
Last time I checked UK was still part of Europe. ;)
--- single minded; short sighted; long gone;
-
Use the format string "N2" to format the number. It will give you the correct format for the current regional settings.
Mark06 wrote:
123,456.78 if I'm in the UK 123.456,78 if I'm in Europe
Last time I checked UK was still part of Europe. ;)
--- single minded; short sighted; long gone;
-
But how do I should I use it? I tried
Label1.text = String.Format(value, "N2")
and it didnt work. As for Europe, appologies, I meant countries like Germany represent decimals and thousand seperators differently to UK.