|
-
Oct 17th, 2010, 04:16 PM
#1
Thread Starter
Hyperactive Member
[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. 
-
Oct 17th, 2010, 05:08 PM
#2
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
-
Oct 17th, 2010, 05:17 PM
#3
Thread Starter
Hyperactive Member
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. 
-
Oct 17th, 2010, 05:49 PM
#4
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|