Format VBScript Funkcja waluty
❮ Pełne odniesienie do VBScript
Funkcja FormatCurrency zwraca wyrażenie sformatowane jako wartość waluty przy użyciu symbolu waluty zdefiniowanego w panelu sterowania komputera.
Składnia
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:
|
Przykłady
Przykład 1
<%
response.write(FormatCurrency(20000))
%>
Wynikiem powyższego kodu będzie:
$20,000.00
Przykład 2
Ustawienie liczby miejsc po przecinku:
<%
response.write(FormatCurrency(20000,2) & "<br />")
response.write(FormatCurrency(20000,5))
%>
Wynikiem powyższego kodu będzie:
$20,000.00
$20,000.00000
Przykład 3
Wartości ułamkowe z wiodącym zerem lub bez niego:
<%
response.write(FormatCurrency(.20,,0) & "<br />")
response.write(FormatCurrency(.20,,-1))
%>
Wynikiem powyższego kodu będzie:
$.20
$0.20
Przykład 4
Wartości ujemne w nawiasach lub nie:
<%
response.write(FormatCurrency(-50,,,0) & "<br />")
response.write(FormatCurrency(-50,,,-1))
%>
Wynikiem powyższego kodu będzie:
-$50.00
($50.00)
Przykład 5
Grupowanie miliona dolarów - lub nie:
<%
response.write(FormatCurrency(1000000,,,,0) & "<br />")
response.write(FormatCurrency(1000000,,,,-1))
%>
Wynikiem powyższego kodu będzie:
$1000000.00
$1,000,000.00
❮ Pełne odniesienie do VBScript