This documentation is archived and is not being maintained.

Strings.FormatCurrency Method

Returns an expression formatted as a currency value using the currency symbol defined in the system control panel.

Namespace: Microsoft.VisualBasic
Assembly: Microsoft.VisualBasic (in microsoft.visualbasic.dll)

Public Shared Function FormatCurrency ( _
	Expression As Object, _
	<OptionalAttribute> Optional NumDigitsAfterDecimal As Integer = -1, _
	<OptionalAttribute> Optional IncludeLeadingDigit As TriState = TriState.UseDefault, _
	<OptionalAttribute> Optional UseParensForNegativeNumbers As TriState = TriState.UseDefault, _
	<OptionalAttribute> Optional GroupDigits As TriState = TriState.UseDefault _
) As String
Dim Expression As Object
Dim NumDigitsAfterDecimal As Integer
Dim IncludeLeadingDigit As TriState
Dim UseParensForNegativeNumbers As TriState
Dim GroupDigits As TriState
Dim returnValue As String

returnValue = Strings.FormatCurrency(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigits)
public static String FormatCurrency (
	Object Expression, 
	/** @attribute OptionalAttribute() */ int NumDigitsAfterDecimal, 
	/** @attribute OptionalAttribute() */ TriState IncludeLeadingDigit, 
	/** @attribute OptionalAttribute() */ TriState UseParensForNegativeNumbers, 
	/** @attribute OptionalAttribute() */ TriState GroupDigits
public static function FormatCurrency (
	Expression : Object, 
	NumDigitsAfterDecimal : int, 
	IncludeLeadingDigit : TriState, 
	UseParensForNegativeNumbers : TriState, 
	GroupDigits : TriState
) : String
Not applicable.



Required. Expression to be formatted.


Optional. Numeric value indicating how many places are displayed to the right of the decimal. Default value is –1, which indicates that the computer's regional settings are used.


Optional. TriState enumeration that indicates whether or not a leading zero is displayed for fractional values. See "Settings" for values.


Optional. TriState enumeration that indicates whether or not to place negative values within parentheses. See "Settings" for values.


Optional. TriState enumeration that indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings. See "Settings" for values.

Return Value

Returns an expression formatted as a currency value using the currency symbol defined in the system control panel.

For more detailed information, see the Visual Basic topic FormatCurrency Function (Visual Basic).

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.


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 IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments take the following TriState enumeration values.








The computer's regional settings

The following example illustrates the use of the FormatCurrency function.

Dim TestDebt As Double = -4456.43
Dim TestString As String
' Returns "($4,456.43)".
TestString = FormatCurrency(TestDebt, , , TriState.True, TriState.True)

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0