Formatting double as currency?
-
Hi All -- I'm probably overlooking a simple API or class, but: Does anyone have sample code for converting a double value to a formatted string using the currency format defined by the system? For example: double dValue = 1234567.89; CString sValue = FormatAsCurrency(dValue); // If we're in the USA, // sValue should be "$1,234,567.89". // If we're in the UK, // sValue should be "£1,234,567.89" I'd be grateful for any suggestions.
-
Hi All -- I'm probably overlooking a simple API or class, but: Does anyone have sample code for converting a double value to a formatted string using the currency format defined by the system? For example: double dValue = 1234567.89; CString sValue = FormatAsCurrency(dValue); // If we're in the USA, // sValue should be "$1,234,567.89". // If we're in the UK, // sValue should be "£1,234,567.89" I'd be grateful for any suggestions.
Use wsprintf() to convert your value to a string, then call GetCurrencyFormat(). Simple! --Mike-- ================== The original message was: Hi All --
I'm probably overlooking a simple API or class, but:
Does anyone have sample code for converting a double value to a formatted string using the currency format defined by the system? For example:
double dValue = 1234567.89;
CString sValue = FormatAsCurrency(dValue);// If we're in the USA,
// sValue should be "$1,234,567.89".
// If we're in the UK,
// sValue should be "£1,234,567.89"I'd be grateful for any suggestions.