VBScriptFormatNumber関数_
❮完全なVBScriptリファレンス
FormatNumber関数は、数値としてフォーマットされた式を返します。
構文
FormatNumber(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(FormatNumber(20000))
%>
上記のコードの出力は次のようになります。
20,000.00
例2
小数点以下の桁数の設定:
<%
response.write(FormatNumber(20000,2) & "<br />")
response.write(FormatNumber(20000,5))
%>
上記のコードの出力は次のようになります。
20,000.00
20,000.00000
例3
先行ゼロの有無にかかわらず小数値:
<%
response.write(FormatNumber(.20,,0) & "<br />")
response.write(FormatNumber(.20,,-1))
%>
上記のコードの出力は次のようになります。
.20
0.20
例4
括弧内の負の値かどうか:
<%
response.write(FormatNumber(-50,,,0) & "<br />")
response.write(FormatNumber(-50,,,-1))
%>
上記のコードの出力は次のようになります。
-50.00
(50.00)
例5
番号のグループ化-またはそうでない:
<%
response.write(FormatNumber(1000000,,,,0) & "<br />")
response.write(FormatNumber(1000000,,,,-1))
%>
上記のコードの出力は次のようになります。
1000000.00
1,000,000.00
❮完全なVBScriptリファレンス