VBScript to demonstrate the use of format functions
kw.vbs
print "Returns an expression formatted as a number: " & FormatNumber(500000)
print "Returns an expression formatted as a number: " & FormatNumber(500000,10)
print "Returns an expression formatted as a number: " & FormatNumber(5000000,,,,-1)
print "Returns an expression formatted as a percentage: " & FormatPercent(1000/10000,1)
print "Returns an expression formatted as a percentage: " & FormatPercent(1000/10000)
print "Returns an expression formatted as a currency value: " & FormatCurrency(-5000,,,,0)
print "Returns Date in Default System Date Format: " & FormatDateTime(Now(), 0)
print "Returns Weekday, Monthname, Year: " & FormatDateTime(Now(), 1)
print "Returns mm/dd/yy: " & FormatDateTime(Now(), 2)
print "Returns hh:mm:ss PM/AM: " & FormatDateTime(Now(), 3)
print "Returns hh:mm: " & FormatDateTime(Now(), 4)
Output
Returns an expression formatted as a number: 500,000.00
Returns an expression formatted as a number: 500,000.0000000000
Returns an expression formatted as a number: 5,000,000.00
Returns an expression formatted as a percentage: 10.0%
Returns an expression formatted as a percentage: 10.00%
Returns an expression formatted as a currency value: ($5000.00)
Returns Date in Default System Date Format: 4/13/2017 6:56:18 PM
Returns Weekday, Monthname, Year: Thursday, April 13, 2017
Returns mm/dd/yy: 4/13/2017
Returns hh:mm:ss PM/AM: 6:56:18 PM
Returns hh:mm: 18:56
Advertisement