Originally Posted by
Gregor y
The difference being that a collection when built properly will only accept one type of object to hold vs an array which doesn't care what it holds.
I guess I need to walk this back a bit, it has been a while since I've had my hands in VBA code.
Arrays in VBA come in many varieties.
you can explicitly give it an object type
or let it hold anything
likewise you can state the size upfront
or figure it out later
or do what I was incorrectly remembering as an Array object
All of these solutions however require you to keep track of: how full the array is, if it needs to be resized, and what you put in which index. (although in this context it makes the most sense to me to have floor(0) be the crawlspace up to floor(4) the attic)
oddly enough the generic collection object is maybe the best fit for this situation, since you wouldn't have to do so much to keep track of its size
there are a few other options
However if you can avoid it I'd probably have you steer away from a truly custom collection class.
I'm not sure what you mean by bury/embed the structure in the code but your custom class objects should show up in the "Object Browser(2)" if you search for them. Keep in mind though that VBA code typically sticks with the workbook unless you share it with others and they put in their PERSONAL.XLS, which is why it's usually built to do a task specific to the project that the workbook is associated with.
Bookmarks