O
OregonMike
I'm a C# guy tasked with fixing some bugs in VB.NET code. I've run
into something that doesn't seem to make sense. I have an Object
reference to a System.Windows.Forms.ToolStripComboBox Object that gets
initialized and performs just fine. Now, when closing the app, this
object gets Disposed. I'm trying to check whether this object is null
(Nothing, I presume) before calling one of its Properties. It seems
pretty simple, but the test for Nothing always fails claiming it's not
Nothing. Then trying to access one of its Properties results in an
NullReferenceException ;( Am I checking whether my reference Object is
null correctly?
Example:
' global scope
Dim cB As ToolStripComboBox
..
..
' Initialization and other good stuff
..
..
' Futhur down in its own Sub
..
If Not cB Is Nothing
cB.SelectedIndex = 1
End If
into something that doesn't seem to make sense. I have an Object
reference to a System.Windows.Forms.ToolStripComboBox Object that gets
initialized and performs just fine. Now, when closing the app, this
object gets Disposed. I'm trying to check whether this object is null
(Nothing, I presume) before calling one of its Properties. It seems
pretty simple, but the test for Nothing always fails claiming it's not
Nothing. Then trying to access one of its Properties results in an
NullReferenceException ;( Am I checking whether my reference Object is
null correctly?
Example:
' global scope
Dim cB As ToolStripComboBox
..
..
' Initialization and other good stuff
..
..
' Futhur down in its own Sub
..
If Not cB Is Nothing
cB.SelectedIndex = 1
End If