Name
IsNull Function
Syntax
IsNull(expression)-
expression Use: Required
Datatype: Any variant
An expression containing string or numeric data.
Return Value
Boolean (True or False).
Description
Determines whether expression contains any
null data.
Rules at a Glance
If the expression passed to
IsNullcontains null data,Trueis returned; otherwise,IsNullreturnsFalse.All variables in
expressionare checked for null data. If null data is found in any one part of the expression,Trueis returned for the entire expression.
Programming Tips & Gotchas
IsNullis useful when returning data from a database. You should check field values in columns that allow Nulls againstIsNullbefore assigning the value to a collection or other variable. This stops the common “Invalid Use of Null” error from occurring.IsNullis the only way to evaluate an expression containing a null. For example, the seemingly correct statement:If varMyVar = Null Then
always evaluates to
False, even ifvarMyVaris null. This occurs because the value of an expression containingNullis alwaysNulland thereforeFalse.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access