Null (constant)


Represents a variant of VarType 1.


The Null value has special meaning indicating that a variable contains no data.

Most numeric operators return Null when either of the arguments is Null. This "propagation" of Null makes it especially useful for returning error values through a complex expression. For example, you can write functions that return Null when an error occurs, then call this function within an expression. You can then use the IsNull function to test the final result to see whether an error occurred during calculation.

Since variants are Empty by default, the only way for Null to appear within a variant is for you to explicitly place it there. Only a few functions return this value.


Sub Main()
  Dim a As Variant
  a = Null
  If IsNull(a) Then MsgBox "The variable is Null."
  MsgBox "The VarType of a is: " & VarType(a) 'Should display 1.
End Sub

More information