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
IsNull
contains null data,True
is returned; otherwise,IsNull
returnsFalse
.All variables in
expression
are checked for null data. If null data is found in any one part of the expression,True
is returned for the entire expression.
Programming Tips & Gotchas
IsNull
is useful when returning data from a database. You should check field values in columns that allow Nulls againstIsNull
before assigning the value to a collection or other variable. This stops the common “Invalid Use of Null” error from occurring.IsNull
is 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 ifvarMyVar
is null. This occurs because the value of an expression containingNull
is alwaysNull
and thereforeFalse
.
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.