รูปแบบ VBScript ฟังก์ชันสกุลเงิน
❮ การอ้างอิง VBScript ที่สมบูรณ์
ฟังก์ชัน FormatCurrency ส่งกลับนิพจน์ที่จัดรูปแบบเป็นค่าสกุลเงินโดยใช้สัญลักษณ์สกุลเงินที่กำหนดไว้ในแผงควบคุมของคอมพิวเตอร์
ไวยากรณ์
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:
|
ตัวอย่าง
ตัวอย่างที่ 1
<%
response.write(FormatCurrency(20000))
%>
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
$20,000.00
ตัวอย่าง 2
การตั้งค่าจำนวนทศนิยม:
<%
response.write(FormatCurrency(20000,2) & "<br />")
response.write(FormatCurrency(20000,5))
%>
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
$20,000.00
$20,000.00000
ตัวอย่างที่ 3
ค่าเศษส่วนที่มีหรือไม่มีศูนย์นำหน้า:
<%
response.write(FormatCurrency(.20,,0) & "<br />")
response.write(FormatCurrency(.20,,-1))
%>
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
$.20
$0.20
ตัวอย่างที่ 4
ค่าลบภายในวงเล็บหรือไม่:
<%
response.write(FormatCurrency(-50,,,0) & "<br />")
response.write(FormatCurrency(-50,,,-1))
%>
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
-$50.00
($50.00)
ตัวอย่างที่ 5
รวมเงินล้าน-หรือไม่:
<%
response.write(FormatCurrency(1000000,,,,0) & "<br />")
response.write(FormatCurrency(1000000,,,,-1))
%>
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
$1000000.00
$1,000,000.00
❮ การอ้างอิง VBScript ที่สมบูรณ์