Re: Number formats problems
- From: "Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 3 Nov 2005 09:38:46 -0000
You're heading for heaps of trouble here. Why are you putting your number in
a String instead of
dim a as double
a = 120.34
This is part of your problem. You're putting a UK/US format number into a
string, and this is causing FormatNumber to try and convert it to a proper
number before it performs the required formatting. It would seem that you're
currently in a locale where "." is the triple character and so that "120.34"
is actually being interpreted as 12,034.00.
If you'd specified the number directly, as shown above, then the
interpretation is unambiguous. VB literals *always* use "." as the decimal
separator, otherwise VB source code would not be portable.
If you want to format the final string representation of your number with a
triple character that isn't the one in the active regional settings (which
doesn't seem a good idea) then you would have to do it manually.
FormatNumber will always acknowledge the user's regional settings
"Prashwee" <prashantha.weerakoon@xxxxxx> wrote in message
> hello All
> I have a very simple question but bit confusing
> First of all i changed my reginal settings to swedish.
> Then i run the simple code below
> dim a as String
> FormatNumber(a, , vbFalse, vbFalse, vbTrue) returns me with 12 234
> I know that "." is for thusand separtor in swdish settings but i am
> expecting a result of 120,34
> how can i achive it?
> The solution should be compatible with any regional setting
> Please help me
> Thanks in advance
- Prev by Date: Re: One thing I noticed
- Next by Date: Re: VB6 and Microsoft and what to do about it.
- Previous by thread: Re: VB.NET Performance
- Next by thread: fading in and out a form