[02/03] Problems with user control
I created a usercontrol with a five dropdown lists that represent a hierarhical tree. The control has a property from which i get a string that represents current selection. The control is NOT added dynamically, neither are controls on it.
The error I get is "Object reference not set to an instance of an object. " when trying to access the property of this control.
If I add the New keyword to
Public WithEvents hier As hierarhija
the error occurs few lines later, when its trying to read .selectedvalue property of dropdown list.
Even stranger is that I use this control about 6 times in a solution, and in one case it works fine using same calls and declarations and i cant find any difference between these forms that would seem important.
Can anybody help me with this?
Re: [02/03] Problems with user control
Obviously you are assuming somewhere that a variable refers to an object when it doesn't. That's the only time you get that error message. The IDE should point you to the line that threw the exception, so you can see it and we can't. You tell us. When the exception is thrown you need to examine the line that threw the exception and determine which reference is Nothing. You can then backtrack to where you expected an object to be assigned to that reference and determine why it wasn't.