To test reference type variables for Nothing values, use the Is operator or the IsNot operator.
Module Module1
Sub Main()
Dim testObject As Object
testObject = Nothing
Console.WriteLine(testObject Is Nothing)
Dim tc As New TestClass
tc = Nothing
Console.WriteLine(tc IsNot Nothing)
End Sub
Class TestClass
Public field1 As Integer
Dim field2 As Boolean
End Class
End Module
Related examples in the same category