I am trying to loop through an array of user defined objects (classes) and am experiencing some difficulties. The code skeleton is as follows.
*************************
dim devices as variant
Sub someroutine
dim onedevice as variant
redim devices(index)
for each onedevice in devices
onedevice.getvalue
next
*******************
The problem seems to be that the object is not initialized so the program errors out. I can make it work by inserting a line "set onedevice = new device" into the loop, but that initializes the object to a 'zero' state and I can't access the value of the object in the array. I suppose I can use a for x = 1 to somelength version, but the for next should work, I think, so I would rather understand what I am doing wrong than work around it.
Any help would be greatly appreciated.
*************************
dim devices as variant
Sub someroutine
dim onedevice as variant
redim devices(index)
for each onedevice in devices
onedevice.getvalue
next
*******************
The problem seems to be that the object is not initialized so the program errors out. I can make it work by inserting a line "set onedevice = new device" into the loop, but that initializes the object to a 'zero' state and I can't access the value of the object in the array. I suppose I can use a for x = 1 to somelength version, but the for next should work, I think, so I would rather understand what I am doing wrong than work around it.
Any help would be greatly appreciated.