Results 1 to 4 of 4

Thread: [RESOLVED] Object Reference Error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Resolved [RESOLVED] Object Reference Error

    Code:
    SystemTree.Nodes(0).Nodes("VIDEO").Nodes.Add(queryObj("Caption"))     <------ This Works
    SystemTree.Nodes(0).Nodes("VIDEO").Nodes(CStr(queryObj("Caption"))).Tag = CStr(queryObj("Caption"))     <----- This Does Not
    Error : Object reference not set to an instance of an object.

    I have a similar piece of code which does not produce the error:

    Code:
    SystemTree.Nodes(0).Nodes("HardDrives").Nodes(CStr(queryObj("Model"))).Tag = queryObj("Index")
    Both Caption and Index are of type string, so why does one work and not the other?

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  2. #2
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Object Reference Error

    I don't know if this would be enaugh, but I noticed that in the first case you are converting the result of the query to a string, and in the working one you are not.
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Object Reference Error

    I tried with and without the CStr in, with the same results.

    COmputerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Object Reference Error

    By adding the highlighted parameter, the error cleared.

    Code:
    SystemTree.Nodes(0).Nodes("VIDEO").Nodes.Add(queryObj("Caption"), queryObj("Caption"))
    MSDN does not make it clear that you need to add this extra parameter for the .TAG to work.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

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