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.

會傳回一個與傳遞過去的值同一類型的值,用於指定某個數字的絕對值。

語法

Abs ( 數字 )

必要 數位引數 可以是任何有效的 數值運算式。 如果 number 包含 Null,就會傳回 Null ;如果是未初始化的 變數,則會傳回零。

註解

數字的絕對值為未簽署的量級。 例如, ABS(-1)ABS(1) 兩者都會傳回 1

查詢範例

Expression

結果​​

SELECT Abs ([Discount]) AS 表達式1 FROM ProductSales;

傳回數據表 Expr1 中數據表 「ProductSales」 之 [折扣] 欄位的絕對值,將負值轉換為正數 (並讓正數) 保持不變。

SELECT Abs ([Discount]/[SalePrice]) AS DiscountPercent FROM ProductSales;

以欄位 「SalePrice」 的百分比來計算欄位 「Discount」 中的所有值,並顯示在 「DiscountPercent」 欄中。

VBA 範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 Abs 函數來計算數字的絕對值。

Dim MyNumber
MyNumber = Abs(50.3) ' Returns 50.3.
MyNumber = Abs(-50.3) ' Returns 50.3.

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!

×