Currency.ToString

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

Currency.ToString(Optional locale As Locale) As String

New in 2019r2

Supported for all project types and targets.

Converts a currency value to a String value using the specified locale.

Notes

To display the currency symbol, you need to pass in a locale. The currency symbol is displayed before or after the number as specified by the locale settings.

If no locale is specified, then Locale.Raw is used.

Sample Code

Convert Currency to Text:

Var c As Currency = 123.45

Var s As String
s = c.ToString ' t = "123.45"

In order to display the currency symbol you need to provide a locale:

Var c As Currency = 123.45

Var s As String
Var locale As New Locale("en-US")
s = c.ToString(locale) ' t = $123.45

This code displays a value using French Canadian locale with the currency symbol after the number:

Var c As Currency = 123.45

Var s As String
Var locale As New Locale("fr-CA")
s = c.ToString(locale) ' t = 123,45 $

See Also

Currency.FromString