Поделиться через


IsNull Function

Returns a Boolean value that indicates whether an expression contains no valid data (Null).

                      IsNull(expression)

Remarks

The expression argument can be any expression.

IsNull returns True if expression is Null, that is, it contains no valid data; otherwise, IsNull returns False.

The Null value indicates that the variable contains no valid data. Null is not the same as Empty, which indicates that a variable has not yet been initialized. It is also not the same as a zero-length string (""), which is sometimes referred to as a null string.

Example

The following example illustrates the use of the IsNull function.

'Dim MyVar, Result

' IsNull returns False.
Result = IsNull(MyVar)

' IsNull returns True.
MyVar = Null
Result = IsNull(MyVar)

' IsNull returns False
MyVar = Empty
Result = IsNull(MyVar)

If the expression consists of more than one variable, Null in any constituent variable causes True to be returned for the entire expression.

' IsNull returns True.
MyVar = Null + 4
Result = IsNull(MyVar)

Expressions that you might expect to evaluate to True under some circumstances, such as If Var = Null and If Var <> Null, are always False. This is because any expression that contains a Null is itself Null, and therefore False.

' This returns False, because an expression
' that contains Null is itself Null.
MyVar = Null
If MyVar = Null Then
    Result = True
Else
    Result = False
End If

Requirements

Version 1

See Also

Reference

IsArray Function

IsDate Function

IsEmpty Function

IsNumeric Function

IsObject Function

VarType Function

Change History

Date

History

Reason

August 2009

Added examples.

Customer feedback.