Re: Beginner level VB.NET question
- From: "Lloyd Sheen" <a@xxx>
- Date: Thu, 27 Sep 2007 15:49:42 -0400
"Anand[MVP]" <AnandMVP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:342C12FC-6C50-4872-A8C3-F85DE1EA5C6C@xxxxxxxxxxxxxxxx
As such the code seems OK, but I just want to check, as you did mention you
were a C# programmer. VB is not case sensitive. So are you just setting the
object to nothing somewhere in the code, but not realizing it is the same
object?
--
Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com
"OregonMike" wrote:
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
What we are not seeing is how the cB variable is set. You have a declaration and then a test. Nothing to set the value or to clear it that we can see.
LS
.
- Follow-Ups:
- Re: Beginner level VB.NET question
- From: OregonMike
- Re: Beginner level VB.NET question
- References:
- Beginner level VB.NET question
- From: OregonMike
- Beginner level VB.NET question
- Prev by Date: Re: How to use WaitforSingleObject on events
- Next by Date: Re: Memory...issues
- Previous by thread: Re: Beginner level VB.NET question
- Next by thread: Re: Beginner level VB.NET question
- Index(es):
Relevant Pages
|