Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Functions
FormatCurrency Function
FormatDateTime Function
FormatNumber Function
FUNCTION: FormatPercent( )
Implemented in version 2.0
FormatPercent
(Expression,
NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigit
)
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%.
There is one mandatory argument.
Expression
The
Expression
argument is the number to be converted to a formatted percent.
Code:
<% =FormatPercent(.77) %>
Output:
77.00%
Note that this function rounds off values.
Code:
<% =FormatPercent(.678999) %>
Output:
67.90%
There are 4 optional arguments.
NumDigitsAfterDecimal
The optional
NumDigitsAfterDecimal
argument allows you to choose the number of digits after the decimal.
Code:
<% =FormatPercent(.123456789, 4) %>
Output:
12.3457%
IncludeLeadingDigit
The optional
IncludeLeadingDigit
argument includes the leading zero.
You must only use the constant or value from the Tristate CONSTANTS for this argument.
CONSTANT
VALUE
DESCRIPTION
TristateTrue
-1
True, will use options
TristateFalse
0
False, will not use options
TristateUseDefault
-2
Use default setting
Code:
<% =FormatPercent(.0098, 4, -1) %>
Output:
0.9800%
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 for this argument.
CONSTANT
VALUE
DESCRIPTION
TristateTrue
-1
True, will use options
TristateFalse
0
False, will not use options
TristateUseDefault
-2
Use default setting
Code:
<% =FormatPercent(-.77, 2, 0, -1) %>
Output:
(77.00%)
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 TRISATE CONSTANTS for this argument.
CONSTANT
VALUE
DESCRIPTION
TristateTrue
-1
True, will use options
TristateFalse
0
False, will not use options
TristateUseDefault
-2
Use default setting
Code:
<% =FormatPercent(.77, 2, 0, -1, -1) %>
Output:
77.00%
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information