[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 :)
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.
Re: Object Reference Error
I tried with and without the CStr in, with the same results.
COmputerman :(
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 :)