Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回格式化為數位的表達式。

語法

FormatNumber ( Expression [NumDigitsAfterDecimal ] [IncludeLeadingDigit ] [UseParensForNegativeNumbers ] [GroupDigits ] )

FormatNumber 函數語法具有下列自變數:

引數

描述

Expression

必要。 要設定格式的表達式。

NumDigitsAfterDecimal

選擇性。 指出小數顯示右邊多少個位置的數值。 默認值為 –1,表示已使用計算機的地區設定。

IncludeLeadingDigit

選擇性。 表示分數值是否顯示前導符零的三州常數。 請參閱值的 [設定] 區段。

UseParensForNegativeNumbers

選擇性。 指出是否要將負值置於括弧內的三州常數。 請參閱值的 [設定] 區段。

GroupDigits

選擇性。 三州常數,指出是否要使用計算機地區設定中指定的群組分隔符來分組數位。 請參閱值的 [設定] 區段。


設定

IncludeLeadingDigit UseParensForNegativeNumbersGroupDigits 自變數具有下列設定:

常數

描述

vbTrue

–1

True

vbFalse

0

False

vbUseDefault

–2

從電腦的地區設定使用此設定。


註解

省略一或多個選用自變數時,計算機的地區設定會提供省略自變數的值。

附註:  所有設定資訊都來自 [ 地區設定號碼 ] 索引標籤。

範例

Expression

結果​​

SELECT FormatNumber ([SalePrice]) AS 表達式1 FROM ProductSales;

將 「SalePrice」 字段中的貨幣值格式化為「數位」格式,並在表達式1 欄中傳回。

SELECT FormatNumber ([Discount],2,-1,-1,-1) 為 ProductSales 的 DiscountedPrice;

將 「折扣」字段中的數位值格式化為「數位」格式,並加上 2 個小數點,所有小於 1 的值在小數點之前都會有「0」。 負值會以括弧括住,值會依預設分隔符分組 (“1000” 會顯示為 1,000.00,“-1000” 會顯示為 (1,000.00) ,“0” 會顯示為 0.00) 。

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×