I understand adding objects to a collection can be done by
Dim ItemList As Collection
Set ItemList = New Collection
Dim Item As New CItem
Set Shoe = New CItem
With Shoe
.Quantity
.IDNumber
.Description
End With
ItemList.Add Shoe
Set Bag = New CItem
With Bag
.Quantity
.IDNumber
.Description
End With
ItemList.Add Bag
I would be able to call data i want to use like (Cost = Bag.Quantity * 2)
However my problem is that my list of items will be user defined. Is there any way to add a variable number of objects into a collection and still be able to retrieve individual data by the item name?
for example, i am given a list of items: Shoe, Bag, Sunglasses, Pants
I would like to write a for loop to read all these objects under the class "Item" but still be able to calculate (xyz = Sunglasses.Quantity + Pants.Quantity - Bag.Quantity). I have tried to use counters, but it seems to only accept constant expressions.
Is this possible? If so, i would appreciate help in finding out how to do it.