VBScript -formaat Geldeenheid- funksie
❮ Voltooi VBScript-verwysing
Die FormatCurrency-funksie gee 'n uitdrukking terug wat as 'n geldeenheidwaarde geformateer is deur gebruik te maak van die geldeenheidsimbool wat in die rekenaar se beheerpaneel gedefinieer is.
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:
|
Voorbeelde
Voorbeeld 1
<%
response.write(FormatCurrency(20000))
%>
Die afvoer van die kode hierbo sal wees:
$20,000.00
Voorbeeld 2
Stel aantal desimale in:
<%
response.write(FormatCurrency(20000,2) & "<br />")
response.write(FormatCurrency(20000,5))
%>
Die afvoer van die kode hierbo sal wees:
$20,000.00
$20,000.00000
Voorbeeld 3
Breukwaardes met of sonder 'n voorste nul:
<%
response.write(FormatCurrency(.20,,0) & "<br />")
response.write(FormatCurrency(.20,,-1))
%>
Die afvoer van die kode hierbo sal wees:
$.20
$0.20
Voorbeeld 4
Negatiewe waardes binne hakies of nie:
<%
response.write(FormatCurrency(-50,,,0) & "<br />")
response.write(FormatCurrency(-50,,,-1))
%>
Die afvoer van die kode hierbo sal wees:
-$50.00
($50.00)
Voorbeeld 5
Groepering van 'n miljoen dollar - of nie:
<%
response.write(FormatCurrency(1000000,,,,0) & "<br />")
response.write(FormatCurrency(1000000,,,,-1))
%>
Die afvoer van die kode hierbo sal wees:
$1000000.00
$1,000,000.00
❮ Voltooi VBScript-verwysing