Returns an expression formatted as a percentage (that is, multiplied by 100) with a trailing % character.
Function FormatPercent( 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 have the following settings:
Constant | Description |
---|---|
TriState.True | True |
TriState.False | False |
TriState.Default | The computer's regional settings |
Exception type | Error number | Condition |
---|---|---|
13 | Type is not numeric. |
When one or more optional arguments are omitted, the values for omitted arguments are provided by the locale 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.
This example illustrates the use of the FormatPercent function:
Dim myNumber As Single = 0.76
Dim myString As String
' Returns "76.00%".
myString = FormatPercent(myNumber)
FormatCurrency Function | FormatDateTime Function | FormatNumber Function | Tristate Enumeration |