Hello. I'm new to working with custom collection classes, etc. I have successfully created a few custom classes and collection classes. I am noticing something that does not seem to make sense though.
For one collection class, I have created a method that returns an object in the collection with the given index. It works like the Item method of the normal vb Collection object.
Once I've added IMS objects to the System, I can call them usingFunction IMS(Index As Variant) As CIMS Set IMS = System_Collection.Item(Index) End Function
where i is the index. So far, so good.System.IMS(i)
The problem I have is that I want to use a selection from a listbox to determine the index of the IMS to be called. The listbox is populate with numbers (1, 2, 3...), so I should be able to use:
as the argument of the IMS method from above. But for some reason, I get an error every time I try that. 'Invalid procedure call or argument'. I don't understand why that happens. The Index argument is a variant, so shouldn't this work? I checked that the listbox value is numeric. And I know the index number is valid. My work-around is that I declare an integer, store the listbox value to it and use that variable as the Index. This makes no sense to me.Sheets(1).ListBox1.value
Any thoughts? Sorry for the long post. Thanks in advance.