Re: dealing with currencies and different locales....
- From: "Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 23 Feb 2006 14:28:07 -0000
A few quick notes Guy...
a) Not all European countries use "," as a decimal separator. Britain and
Ireland, for instance, use ".", and always will
b) Val ( & Str) is not locale-aware, and will always expect a "." decimal
separator. This can be useful in a few circumstances
c) CDbl will only accept the correct currency representation for your
current locale, e.g. in Britain, CDbl("£10.34") - which is also my salary -
works, but CDbl("$10.34") fails with 'Type mismatch'
Tony Proctor
"G Doucet" <someone@xxxxxxxxxxxxxxx> wrote in message
news:MUpKf.32703$VV4.377318@xxxxxxxxxxxxxxxxxxxxxxxxxx
I'd like to share what I have found today. I'm just wondering if this isthe correct way to deal with currencies. In the past
(like until this morning) I used to use something like this:box. One problem: the Val() function would return 0 if
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
I included the dollar sign. The other problem occured when I used adifferent 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.This would not only get the correct value, but it would
Reading in my VB5 help, I found that I should use CDbl() instead of Val().
allow me to include the dollar sign in the example above.mismatch errors at times when my locale wasn't set to US.
I was still getting some problems with CDbl() however. I would get type
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.symbol) is displayed at the right, like "10,00 $". That's
Besides that, I noticed that in other locales, the dollar sign (or Euro
when I realised that the Format function wasn't working well for me.name such as:
Finally, I found that I could use the Format() function using a format
this:
Text1.Text = Format(cCOSTA, "Currency")
I also found that the best way to preset my text boxes to zero is like
boxes and then reading them again?
Text1.Text = Format(0, "Currency")
Is there anything else I should know about displaying currencies in text
Guy
.
- Follow-Ups:
- Re: dealing with currencies and different locales....
- From: Mike Williams
- Re: dealing with currencies and different locales....
- References:
- dealing with currencies and different locales....
- From: G Doucet
- dealing with currencies and different locales....
- Prev by Date: open form from different project
- Next by Date: Re: open form from different project
- Previous by thread: Re: dealing with currencies and different locales....
- Next by thread: Re: dealing with currencies and different locales....
- Index(es):
Relevant Pages
|