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.

會傳回數字的整數部分。

語法

Int ( 數字 )

修正 ( 數字 )

必要 數位引數 為 Double 或任何有效的 數值運算式。 如果 number 包含 Null,就會傳回 Null

註解

IntFix 都會移除 number 的分數部分,並傳回產生的整數值。

IntFix 之間的差異在於,如果 number 是負數,Int 會傳回小於或等於 number 的第一個負整數,而 Fix 會傳回大於或等於 number 的第一個負整數例如 Int 轉換 -8.4 到 -9,而 Fix 會轉換為 -8.4 到 -8。

修正 (數字) 等於:

Sgn(number) * Int(Abs(number))

查詢範例

Expression

結果​​

SELECT Int ([Discount]) As 表達式1 FROM ProductSales;

拿掉欄位「折扣」中所有值的分數部分,並傳回產生的整數值。 如果是負分數,“Int” 會傳回第一個小於或等於 number 的負整數。 例如,對於折扣值 “-223.20”,傳回的整數為 -224.00。

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

拿掉欄位「折扣」中所有值的分數部分,並傳回產生的整數值。 對於負數分數,「修正」會傳回第一個大於或等於數位的負整數。 例如,針對折扣值 “-223.20”,傳回的整數為 -223.00。

VBA 範例

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

此範例說明 IntFix 函數如何傳回數位的整數部分。 如果是負數自變數, Int 函數會傳回第一個小於或等於該數字的負整數; Fix 函數會傳回第一個大於或等於該數位的負整數。

Dim MyNumber
MyNumber = Int(99.8) ' Returns 99.
MyNumber = Fix(99.2) ' Returns 99.
MyNumber = Int(-99.8) ' Returns -100.
MyNumber = Fix(-99.8) ' Returns -99.
MyNumber = Int(-99.2) ' Returns -100.
MyNumber = Fix(-99.2) ' Returns -99.

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!

×