FormatNumber

Format a number.

Syntax 
      FormatNumber(number [,DecimalPlaces [,IncludeLeadingZero
          [,UseParenthesis [, GroupDigits]]]] )

Key
   number              The number to format.
 
   DecimalPlaces       Number of digits to display after the decimal point.

   IncludeLeadingZero  Include a leading zero for numbers <1 and > -1

   UseParenthesis      Show negative numbers in Parentheis (500) = -500

   GroupDigits         Group large numbers with commas (or the regional delimiter)

Examples

Set intDemo = 150000.56
WScript.Echo FormatNumber(intDemo,1)

PowerShell equivalent, display 6 digits beyond the decimal point:

$num = 11
$num = "{0:N6}" -f $num

“A good decision is based on knowledge and not on numbers” ~ Plato

Related VBScript commands

FormatCurrency - Format a number with a currency symbol.
FormatPercent - Format a number with a % symbol.
FormatDateTime - Format a Date/Time value.
Equivalent PowerShell: $myVar = "{0:N4}" -f 150 Will display 150.0000 (4 decimal places).


 
Copyright © 1999-2025 windevcluster.com
Some rights reserved