Συνάρτηση FormatPercent του VBScript

Ορισμός και χρήση

Η συνάρτηση FormatPercent μπορεί να επιστρέψει μια έκφραση που έχει μορφοποιηθεί ως ποσοστό (με τον πήχη % που πολλαπλασιάζεται με 100).

Γλωσσική

FormatPercent(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
Parameters Description
expression Required. The expression to be formatted.
NumDigAfterDec Indicates the number of digits to display to the right of the decimal point. The default value is -1 (the computer's regional settings are used).
IncLeadingDig Optional. Indicates whether to display leading zeros (leading zero) for decimal values:
  • -2 = TristateUseDefault - Χρησιμοποιεί τις ρυθμίσεις της περιοχής του υπολογιστή.
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
UseParForNegNum Optional. Indicates whether to place negative values in parentheses.
  • -2 = TristateUseDefault - Χρησιμοποιεί τις ρυθμίσεις της περιοχής του υπολογιστή.
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
GroupDig Optional. Indicates whether to use the number grouping symbol specified in the computer's regional settings to group numbers.
  • -2 = TristateUseDefault - Χρησιμοποιεί τις ρυθμίσεις της περιοχής του υπολογιστή.
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False

Instance

Example 1

6 is what percentage of 345?
document.write(FormatPercent(6/345))

Output:

1.74%

Example 2

6 is what percentage of 345?
document.write(FormatPercent(6/345,1))

Output:

1.7%