The VBA IsNull Function


The VBA IsNull function returns a Boolean, indicating whether a supplied expression is Null.

The syntax of the function is:

IsNull( Expression )

Where the supplied Expression is the expression that you want to test.

VBA IsNull Function Examples

The following example supplies three different variables to the VBA IsNull function.

' Test if three variables are Null.
Dim var1, var2, var3
Dim isNull1 As Boolean
Dim isNull2 As Boolean
Dim isNull3 As Boolean
var1 = 5
isNull1 = IsNull( var1 )
' The variable isNull1 is now equal to False.
var2 = Null
isNull2 = IsNull( var2 )
' The variable isNull2 is now equal to True.
isNull3 = IsNull( var3 )
' The variable isNull3 is now equal to False.

The above examples show that the IsNull function returns: