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.

會傳回 Boolean 值,指出 運算式 是否未包含任何有效數據 (Null) 。

語法

IsNull ( 表示 式)

必要 表達 式引數 是包含 數值運算式 或 字串運算式的 Variant。

註解

如果 expressionNull,IsNull傳回 True;否則,IsNull 會傳回 False。 如果 表達式 包含一個以上的 變數,則任何組成變數中的 Null 都會造成整個表達式傳回 True

Null 值表示 Variant 不包含任何有效數據。 Null 與 空白不同,這表示變數尚未初始化。 它也與零長度字串 (“) 不同,有時也稱為 Null 字串。

重要:  使用 IsNull 函數來判斷表達式是否包含 Null 值。 在某些情況下,例如 If Var = NullIf Var <> Null等,您可能會預期評估為 True 的運算式一律為 False。 這是因為包含 Null 的任何表達式本身即 為 Null ,因此為 False

查詢範例

Expression

結果​​

SELECT ProductID, isNull (Discount) AS Expr1 FROM ProductSales;

傳回 「ProductID」 字段的值、評估字段 「Discount」 中的值是否為 Null、傳回 -1 (True) 和 0 (Expr1 欄中的 False) 。

SELECT ProductID, isNull (Discount) AS NullStatus FROM ProductSales;

傳回 「ProductID」 字段的值、評估字段 「Discount」 中的值是否為 Null、傳回 -1 (True) 和 0 (NullStatus 欄中的 False) 。

VBA 範例

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

此範例使用 IsNull 函數來判斷變數是否包含 Null

Dim MyVar, MyCheck
MyCheck = IsNull(MyVar) ' Returns False.
MyVar = ""
MyCheck = IsNull(MyVar) ' Returns False.
MyVar = Null
MyCheck = IsNull(MyVar) ' Returns True.

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!

×