I am using a For Each loop to go through a Variant array in VB6. At one point, I want to convert the element of the loop (elem), which is a Variant, to a Node.
Dim elem as Variant
For Each elem In ndArray
Dim nodle As Node
nodle = CType(elem , Node)
Next
That's not the whole loop, but it gives you an idea of what I'm trying to do. When I run this code, I get an error saying "Variable not defined", which points to the 'Node' in the CType method. This is not a variable, it is a type and the method should know that since it is expecting a type.
I tried skipping the CType method and just making nodle = elem, but I got an error saying "Object variable or With block variable not defined". I added the Set keyword in front of the expression and the error changed to "Object required"
When I debug and look at the elem variable, it appears to contain a valid Node value.
Anyone know what's going on here? Is this conversion even possible?
Any suggestions would be greatly appreciated.