FormatPercent - VBScript



The FormatPercent function in VB Script formats a number as a percentage with a specified number of decimal places.


FormatPercent(number, decimals)


  • number: Required. The number to format as a percentage.
  • decimals: Optional. The number of decimal places to display. Default is 2.


  • Format a number as a percentage with two decimal places:
FormatPercent(0.54321, 2) ' Returns "54.32%"
  • Format a number as a percentage with no decimal places:
FormatPercent(0.54321, 0) ' Returns "54%"

Common Issues

  • Empty strings are not converted to numbers, so FormatPercent may return an error for empty strings.
  • Numbers that are too large or too small may cause overflow or underflow errors.


FormatPercent can be combined with other VB Script functions to perform complex formatting tasks. For example, you can use it with the FormatNumber function to format a number with both percentage and currency formatting:

FormatNumber(0.54321, 2, False, True) ' Returns "$54.32%"

Related Commands

  • FormatCurrency
  • FormatDate
  • FormatNumber