Funkce VBScript FormatCurrency


❮ Kompletní VBScript Reference

Funkce FormatCurrency vrací výraz naformátovaný jako hodnota měny pomocí symbolu měny definovaného v ovládacím panelu počítače.

Syntax

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

Parameter Description
expression Required. The expression to be formatted
NumDigAfterDec Optional. Indicates how many places to the right of the decimal are displayed. Default is -1 (the computer's regional settings are used)
IncLeadingDig Optional. Indicates whether or not a leading zero is displayed for fractional values:
  • -2 = TristateUseDefault - Use the computer's regional settings
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
UseParForNegNum Optional. Indicates whether or not to place negative values within parentheses:
  • -2 = TristateUseDefault - Use the computer's regional settings
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
GroupDig Optional. Indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings:
  • -2 = TristateUseDefault - Use the computer's regional settings
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False

Příklady

Příklad 1

<%

response.write(FormatCurrency(20000))

%>

Výstupem výše uvedeného kódu bude:

$20,000.00

Příklad 2

Nastavení počtu desetinných míst:

<%

response.write(FormatCurrency(20000,2) & "<br />")
response.write(FormatCurrency(20000,5))

%>

Výstupem výše uvedeného kódu bude:

$20,000.00
$20,000.00000

Příklad 3

Zlomkové hodnoty s nebo bez úvodní nuly:

<%

response.write(FormatCurrency(.20,,0) & "<br />")
response.write(FormatCurrency(.20,,-1))

%>

Výstupem výše uvedeného kódu bude:

$.20
$0.20

Příklad 4

Záporné hodnoty v závorkách nebo ne:

<%

response.write(FormatCurrency(-50,,,0) & "<br />")
response.write(FormatCurrency(-50,,,-1))

%>

Výstupem výše uvedeného kódu bude:

-$50.00
($50.00)

Příklad 5

Seskupení milionu dolarů – nebo ne:

<%

response.write(FormatCurrency(1000000,,,,0) & "<br />")
response.write(FormatCurrency(1000000,,,,-1))

%>

Výstupem výše uvedeného kódu bude:

$1000000.00
$1,000,000.00

❮ Kompletní VBScript Reference