FormatPercent function
Returns an expression that has been formatted as a percentage of trailing% symbols (multiplied by 100).
FormatPercent(expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])
The syntax for the FormatPercent function has the following parameters:
Parameters
Expression
Required option. The expression to be formatted.
Numdigitsafterdecimal
Options available. A numeric value indicating the number of digits displayed to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.
IncludeLeadingDigit
Options available. A three-state constant that indicates whether to display a decimal value of 0 in the front. For numeric values, see the "Settings" section.
UseParensForNegativeNumbers
Options available. A three-state constant that indicates whether negative values are placed in parentheses. For numeric values, see the "Settings" section.
GroupDigits
Options available. A three-state constant that indicates whether numbers are grouped by using the numeric grouping symbols specified in the computer locale. For numeric values, see the "Settings" section.
Set up
The IncludeLeadingDigit, useparensfornegativenumbers, and GroupDigits parameters can have the following values:
| Constants |
value |
Description |
| TristateTrue |
-1 |
True |
| Tristatefalse |
0 |
False |
| Tristateusedefault |
-2 |
Use the settings in your computer's regional settings. |
Description
When one or more optional arguments are omitted, the computer locale provides the value of the omitted parameter.
Note that all settings information is taken from the Number tab of the locale.
The following example uses the formatpercent function to format an expression as a percentage:
Dim mypercentmypercent = FormatPercent ( 2/32 ) " Mypercent contains 6.25% .