dealing with currencies and different locales....
- From: "G Doucet" <someone@xxxxxxxxxxxxxxx>
- Date: Mon, 20 Feb 2006 20:46:36 GMT
I'd like to share what I have found today. I'm just wondering if this is the correct way to deal with currencies. In the past
(like until this morning) I used to use something like this:
Text1.Text = Format(cCOSTA,"#,0.00").
' ...
cCOSTB = Val(Text1.Text)
This would give me problems when I tried to retrieve the value of the text box. One problem: the Val() function would return 0 if
I included the dollar sign. The other problem occured when I used a different locale. It turns out that European countries (as
far as I know), will display 10 euros as "10,00" instead of "10.00", - the decimal point is replaced by a comma. So now Val()
doesn't work because of the comma.
Reading in my VB5 help, I found that I should use CDbl() instead of Val(). This would not only get the correct value, but it would
allow me to include the dollar sign in the example above.
I was still getting some problems with CDbl() however. I would get type mismatch errors at times when my locale wasn't set to US.
I found out later that it was because I had preset some text boxes with "0.00" and the CDbl() function was expecting "0,00" - with
the comma.
Besides that, I noticed that in other locales, the dollar sign (or Euro symbol) is displayed at the right, like "10,00 $". That's
when I realised that the Format function wasn't working well for me.
Finally, I found that I could use the Format() function using a format name such as:
Text1.Text = Format(cCOSTA, "Currency")
I also found that the best way to preset my text boxes to zero is like this:
Text1.Text = Format(0, "Currency")
Is there anything else I should know about displaying currencies in text boxes and then reading them again?
Guy
.
- Follow-Ups:
- Re: dealing with currencies and different locales....
- From: Tony Proctor
- Re: dealing with currencies and different locales....
- From: Steve Gerrard
- Re: dealing with currencies and different locales....
- From: Frank Adam
- Re: dealing with currencies and different locales....
- From: Bert van den Dongen
- Re: dealing with currencies and different locales....
- Prev by Date: Re: API Status Bar - Mike?
- Next by Date: File querry
- Previous by thread: API Status Bar - Mike?
- Next by thread: Re: dealing with currencies and different locales....
- Index(es):
Relevant Pages
|