Version: 2.0
-
Syntax:
-
FormatPercent(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit,
UseParensForNegativeNumbers, GroupDigit)
- Expression
- The Expression argument is the number to be converted to a
formatted percent.
- NumDigitsAfterDecimal
- The optional NumDigitsAfterDecimal argument allows you to
choose the number of digits after the decimal.
- IncludeLeadingDigit
- The optional IncludeLeadingDigit argument includes the leading
zero.
You must only use the constant or value from the Tristate Constants table for this argument.
- UseParensForNegativeNumbers
- The optional UseParensForNegativeNumber argument replaces a
negative sign with parentheses around the number.
You must only use the constant or value from the Tristate Constants table for this argument. - GroupDigit
- The optional GroupDigit argument allows the use of the options
specified in the Regional Settings Properties in the Control Panel to
display a percent.
You must only use the constant or value from the Tristate Constants table for this argument.
The FormatPercent function return a formatted percent value for
the numeric expression with a following percent sign (%). A 1.0
converts to 100% and 0.0 converts to 0%.
Tristate Constants
| CONSTANT |
VALUE |
DESCRIPTION |
| TristateTrue |
-1 |
True, will use options |
| TristateFalse |
0 |
False, will not use options |
| TristateUseDefault |
-2 |
Use
default setting |
|
Examples
Code:
<% =FormatPercent(.77) %>Output:
77.00%
Language(s):
VBScript
Code:
<% =FormatPercent(.678999) %>Output:
67.90%
Language(s):
VBScript
Code:
<% =FormatPercent(.123456789, 4)
%>Output:
12.3457%
Language(s):
VBScript
Code:
<% =FormatPercent(.0098, 4, -1) %>Output:
0.9800%
Language(s):
VBScript
Code:
<% =FormatPercent(-.77, 2, 0, -1) %>Output:
(77.00%)
Language(s):
VBScript
Code:
<% =FormatPercent(.77, 2, 0, -1, -1)
%>Output:
77.00%
Language(s):
VBScript
See Also: