Returns an expression formatted as a currency value using the currency symbol defined in the system control panel.
Function FormatCurrency( ByVal Expression As Object, Optional ByVal NumDigitsAfterDecimal As Integer = -1, Optional ByVal IncludeLeadingDigit As TriState = TriState.UseDefault, Optional ByVal UseParensForNegativeNumbers As TriState = TriState.UseDefault, Optional ByVal GroupDigits As TriState = TriState.UseDefault ) As String
The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments take the following Tristate enumeration values:
Value | Description |
---|---|
TriState.True | True |
TriState.False | False |
TriState.UseDefault | The computer's regional settings |
Exception type | Error number | Condition |
---|---|---|
5 | Number of digits after decimal point is greater than 99. | |
13 | Type is not numeric. |
When one or more optional arguments are omitted, the computer's matching regional-settings values are used instead.
The position of the currency symbol relative to the currency value is determined by the system's regional settings.
Note All settings information comes from the locale of the application. By default, that will be the locale set in the control panel. However, it may be changed programmatically by using the .NET Framework, except leading zero, which comes from the Number tab.
The following example illustrates the use of the FormatCurrency function.
Dim myDebt As Double = -4456.43 Dim myString As String ' Returns"($4,456.43)". MyString = FormatCurrency(myDebt,,, TriState.True, TriState.True)
FormatDateTime Function | FormatNumber Function | FormatPercent Function | Tristate Enumeration |