Fungsi Mata Uang Format VBScript
Referensi VBScript Lengkap
Fungsi FormatCurrency mengembalikan ekspresi yang diformat sebagai nilai mata uang menggunakan simbol mata uang yang ditentukan di panel kontrol komputer.
Sintaksis
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:
|
Contoh
Contoh 1
<%
response.write(FormatCurrency(20000))
%>
Output dari kode di atas akan menjadi:
$20,000.00
Contoh 2
Mengatur jumlah desimal:
<%
response.write(FormatCurrency(20000,2) & "<br />")
response.write(FormatCurrency(20000,5))
%>
Output dari kode di atas akan menjadi:
$20,000.00
$20,000.00000
Contoh 3
Nilai pecahan dengan atau tanpa nol di depan:
<%
response.write(FormatCurrency(.20,,0) & "<br />")
response.write(FormatCurrency(.20,,-1))
%>
Output dari kode di atas akan menjadi:
$.20
$0.20
Contoh 4
Nilai negatif di dalam tanda kurung atau tidak:
<%
response.write(FormatCurrency(-50,,,0) & "<br />")
response.write(FormatCurrency(-50,,,-1))
%>
Output dari kode di atas akan menjadi:
-$50.00
($50.00)
Contoh 5
Mengelompokkan satu juta dolar - atau tidak:
<%
response.write(FormatCurrency(1000000,,,,0) & "<br />")
response.write(FormatCurrency(1000000,,,,-1))
%>
Output dari kode di atas akan menjadi:
$1000000.00
$1,000,000.00
Referensi VBScript Lengkap