Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

VBScript FormatNumber function


May 13, 2021 VBScript


Table of contents


VBScript FormatNumber function


VBScript FormatNumber function Complete VBScript reference manual

The FormatNumber function returns an expression that is formatted as a number.

Grammar

FormatNumber(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])

parameter describe
expression Required.It is necessary to format the expression.
NumDigAfterDec Optional.Indicates the value of the number of digits on the right side of the decimal point.The default value is -1 (used by the area setting of the computer).
IncLeadingDig Optional.Indicates whether the leading zero of the small value is displayed:
  • -2 = TristateuseDefault - Using the area of the computer
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
UseParForNegNum Optional.Indicates whether the negative value is placed in parentheses:
  • -2 = TristateuseDefault - Using the area of the computer
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
GroupDig Optional.Indicates whether the number packet symbol specified in the computer area setting will group numbers:
  • -2 = TristateuseDefault - Using the area of the computer
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False

Instance 1

<script type="text/vbscript">

document.write(FormatNumber(20000))

</script>

The above example output results:

20,000.00

Try it out . . .

Instance 2

Set the number of places after the scale:

<script type="text/vbscript">

document.write(FormatNumber(20000,2) & "<br />")
document.write(FormatNumber(20000,5))

</script>

The above example output results:

20,000.00
20,000.00000

Try it out . . .

Instance 3

Whether to display the leading zero of the small number:

<script type="text/vbscript">

document.write(FormatNumber(.20,,0) & "<br />")
document.write(FormatNumber(.20,,-1))

</script>

The above example output results:

.20
0.20

Try it out . . .

Instance 4

Whether to put a negative value in parentheses:

<script type="text/vbscript">

document.write(FormatNumber(-50,,,0) & "<br />")
document.write(FormatNumber(-50,,,-1))

</script>

The above example output results:

-50.00
(50.00)

Try it out . . .

Instance 5

Whether to group numbers:

<script type="text/vbscript">

document.write(FormatNumber(1000000,,,,0) & "<br />")
document.write(FormatNumber(1000000,,,,-1))

</script>

The above example output results:

1000000.00
1,000,000.00

Try it out . . .

VBScript FormatNumber function Complete VBScript reference manual