|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
FormatCurrency Function (Visual Basic)
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
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.
|Exception type||Error number||Condition|
Number of digits after decimal point is greater than 99.
Type is not numeric.
See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the.) However, when possible, you should consider replacing such error control with .
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.
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)