G
George
I'm new to class modules. As an exercise, I thought It might be useful to
create a collection of properties in a class, so one could iterate through
the properties by number.
I tried varous combinations of the following:
Private Sub Class_Initialize()
Set Me.Properties = New Collection
Me.Properties.Add Me.BusinessAddress, "BusinessAddress"
Me.Properties.Add Me.BusinessAddressCity, "BusinessAddressCity"
Me.Properties.Add Me.BusinessAddressCountry, "BusinessAddressCountry"
End Sub
I expected to be able to create a pointer to the property as item in the
collection, such that setting the property would update the item in the
collection. But that does not work; instead the old value is retained.
I can create a subroutine to update the value of each item in the collection
as it's property is set, but I wonder:
Is it possible to add properties to a collection such that updating the
property's
value causes the collection's item (corresponding to the property) to
take the
new value of the property? Similarly, updating the collection item's
value would
update the corresponding property.
If I am completely misunderstanding what I'm supposed to be doing here, with
classes and collections, please enlighten me.
Thank you in advance for your time.
George
create a collection of properties in a class, so one could iterate through
the properties by number.
I tried varous combinations of the following:
Private Sub Class_Initialize()
Set Me.Properties = New Collection
Me.Properties.Add Me.BusinessAddress, "BusinessAddress"
Me.Properties.Add Me.BusinessAddressCity, "BusinessAddressCity"
Me.Properties.Add Me.BusinessAddressCountry, "BusinessAddressCountry"
End Sub
I expected to be able to create a pointer to the property as item in the
collection, such that setting the property would update the item in the
collection. But that does not work; instead the old value is retained.
I can create a subroutine to update the value of each item in the collection
as it's property is set, but I wonder:
Is it possible to add properties to a collection such that updating the
property's
value causes the collection's item (corresponding to the property) to
take the
new value of the property? Similarly, updating the collection item's
value would
update the corresponding property.
If I am completely misunderstanding what I'm supposed to be doing here, with
classes and collections, please enlighten me.
Thank you in advance for your time.
George