O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

FormatCurrency, FormatNumber, FormatPercent Functions

Syntax

FormatCurrency(number[,DecimalPlaces ][, _
     IncLeadingZero[,UseParenthesis[,GroupDigits]]]]) 
FormatNumber(number[,DecimalPlaces ][, _
     IncLeadingZero[,UseParenthesis[,GroupDigits]]]]) 
FormatPercent(number[,DecimalPlaces ][, _
     IncLeadingZero[,UseParenthesis[,GroupDigits]]]])
number

Use: Required

Data Type: Any numeric expression

The number to be formatted.

DecimalPlaces

Use: Optional

Data Type: Long

Number of digits the formatted string should contain after the decimal point.

IncLeadingZero

Use: Optional

Data Type: Long

Indicates whether the formatted string is to have a 0 before floating-point numbers between 1 and -1.

UseParenthesis

Use: Optional

Data Type: Long

Specifies whether parentheses should be placed around negative numbers.

GroupDigits

Use: Optional

Data Type: Long

Determines whether digits in the returned string should be grouped using the delimiter specified in the computer’s regional settings. For example, on American English systems, the value 1000000 is returned as 1,000,000 if GroupDigits is True.

Return Value

String

Description

The three functions are almost identical. They all take identical arguments. The only difference is that FormatCurrency returns a formatted number beginning with the currency symbol specified in the computer’s regional settings, while FormatNumber returns just the formatted number, and FormatPercent returns the formatted number followed by a percentage sign (%).

Rules at a Glance

  • If DecimalPlaces isn’t ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required