IsNull - VBScript


The IsNull command in VB Script evaluates whether a given expression or variable is null. It’s commonly used for error handling and flow control.


IsNull(expression, [comparison])


  • expression: The expression or variable to evaluate.
  • comparison: An optional value to compare the expression against (default: 0).




' Check if a variable is null
If IsNull(myVar) Then
    ' Do something
End If

' Check if a property is null
If IsNull(obj.myProperty) Then
    ' Do something
End If

' Check if a function call returns null
If IsNull(GetMyData()) Then
    ' Do something
End If

' Compare the result with a different value
If IsNull(myVar, 10) Then
    ' Do something
End If

Common Issues

  • Type Mismatches: Ensure that the expression being evaluated is compatible with the comparison value.
  • Nested IsNulls: Multiple nested IsNull calls can lead to unexpected results. Use caution when using this command within other expressions.


IsNull can be used in conjunction with the following commands:

  • If/Else statements: For conditional branching based on null values.
  • Nz function: To replace null values with a specified value.
  • IsEmpty function: To check for empty or uninitialized variables.
  • IsEmpty
  • Nz
  • Null keyword