Funzione VBScript FormatCurrency
❮ Riferimento completo di VBScript
La funzione FormatCurrency restituisce un'espressione formattata come valore di valuta utilizzando il simbolo di valuta definito nel pannello di controllo del computer.
Sintassi
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:
|
UseParForNegNum | Optional. Indicates whether or not to place negative
values within parentheses:
|
GroupDig | Optional. Indicates whether or not numbers are grouped
using the group delimiter specified in the computer's regional settings:
|
Esempi
Esempio 1
<%
response.write(FormatCurrency(20000))
%>
L'output del codice sopra sarà:
$20,000.00
Esempio 2
Impostazione del numero di decimali:
<%
response.write(FormatCurrency(20000,2) & "<br />")
response.write(FormatCurrency(20000,5))
%>
L'output del codice sopra sarà:
$20,000.00
$20,000.00000
Esempio 3
Valori frazionari con o senza zero iniziale:
<%
response.write(FormatCurrency(.20,,0) & "<br />")
response.write(FormatCurrency(.20,,-1))
%>
L'output del codice sopra sarà:
$.20
$0.20
Esempio 4
Valori negativi tra parentesi o meno:
<%
response.write(FormatCurrency(-50,,,0) & "<br />")
response.write(FormatCurrency(-50,,,-1))
%>
L'output del codice sopra sarà:
-$50.00
($50.00)
Esempio 5
Raggruppando un milione di dollari - o meno:
<%
response.write(FormatCurrency(1000000,,,,0) & "<br />")
response.write(FormatCurrency(1000000,,,,-1))
%>
L'output del codice sopra sarà:
$1000000.00
$1,000,000.00
❮ Riferimento completo di VBScript