FormatCurrency for idiots

B

buncs

I've been to the help for FormatCurrency and got

net = FormatCurrency(net, 2

But if the value has no decimals I still want the .00 to show. There doesn't seem to be an option, but surely it should be a default with currency. Also .5 should show as .50, should it not

I am obviously missing something.

Also, if you define DIM net As Currency, I would have expected it to behave as currency, otherwise what is the point of defining it as currency?
 
J

Jezebel

Currency as a data type refers to its *internal* format and thus precision.
It has nothing to do with the display format. There are many currencies that
don't use two decimal places, but which use the Currency data type none the
less.

You can format a number for two decimal places using

netString = format(net, "#,###,##0.00") which will give you thousand
separators and two decimal places, using whatever is in your regional
settings as the thousand and decimal separators respectively. (Normally
comma and period; but continental Europe often uses the reverse.) There are
many options, including, if you need them, separate formats for negative,
zero, and null values.

Note that formatting is always about creating strings for human display; it
has nothing to do with the underlying data values.



buncs said:
I've been to the help for FormatCurrency and got:

net = FormatCurrency(net, 2)

But if the value has no decimals I still want the .00 to show. There
doesn't seem to be an option, but surely it should be a default with
currency. Also .5 should show as .50, should it not?
I am obviously missing something.

Also, if you define DIM net As Currency, I would have expected it to
behave as currency, otherwise what is the point of defining it as currency?
 
Top