Results 1 to 2 of 2

Thread: [02/03] Problems with user control

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    2

    [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?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width