檢查 NULL 或空欄位 - 快捷方式

要獲得 Null 或 Empty 檢查的較短版本,請使用“= Nothing”比較。

Iif(Fields!UserEmail.Value = Nothing, "Null or Empty", "Not Null or Empty")

“= Nothing”將同時檢查 Null 或 Empty,給出更緊湊的表示式。這適用於 String,Numeric 和 Boolean。來自 MSDN:

Nothing represents the default value of a data type. The default value depends on whether the variable is of a value type or of a reference type.
A variable of a value type directly contains its value. Value types include all numeric data types, Boolean, Char, Date, all structures, and all enumerations. A variable of a reference type stores a reference to an instance of the object in memory. Reference types include classes, arrays, delegates, and strings. For more information, see Value Types and Reference Types.
If a variable is of a value type, the behavior of Nothing depends on whether the variable is of a nullable data type. To represent a nullable value type, add a ? modifier to the type name. Assigning Nothing to a nullable variable sets the value to null.

如果它們為 null 或空字串“”,則 String 將等於 Nothing。

如果數字為 0,數字將等同於 Nothing。

如果他們是假的,布林人將等同於 Nothing。

有關型別和預設值的完整列表,請檢查(當前)MSDN 頁面是否為 Nothing