W
William H. Burling
i have a nest of vb.vanilla collections.
CollectionofHotelData.item("great Pequot").item("2000").item(22)
The above works. I wrote the code that constructs the nested collections
and i can pull out anything i want within the collections of collections.
However, I want to make my code more readable.
Hence I would like to write it to result in the following:
CollectionofHotelData.Hotel("Great Pequot").Year("2000").SvcPeriod(22)
So I want is to change the vb collection keyword, "item", to something
unique in each collection.(ie: Hotel,Year,SvcPeriod)
What is the smartest way to achieve the above?
I am confused about whether to achieve the result via the use of
"interfaces" (is this only a vb.net feature or is it also in vb.vanilla?)
or through the creation of a new class.
It seems to me that this is a great problem to learn about inheritance,
regardless of whether I achieve the results through classes or interfaces.
I suspect that I could inherit the VB collection class and just include
ONLY the code for the overloaded "item" method (is that correct terminology
for this situation?). I have never "inherited" anything so
I do not know what is really involved yet.
I assume that I would alter the item method (isn't item a method in
vb.vanilla)
like this:
Public Property Get HOtel(VntIndexKey as variant)
set Hotel = mcol(vntindexkey)
End Property
I am not sure if I have to declare mcol as a collection since the base
class
VBcollection already has mcol declared.
I know I have to put the following at the head of the module:
Public Class Collection
Inherits Collection
Also...i am not sure I understand the difference between "shadowing" and
overriding.
Thank you for your help.
Bil
CollectionofHotelData.item("great Pequot").item("2000").item(22)
The above works. I wrote the code that constructs the nested collections
and i can pull out anything i want within the collections of collections.
However, I want to make my code more readable.
Hence I would like to write it to result in the following:
CollectionofHotelData.Hotel("Great Pequot").Year("2000").SvcPeriod(22)
So I want is to change the vb collection keyword, "item", to something
unique in each collection.(ie: Hotel,Year,SvcPeriod)
What is the smartest way to achieve the above?
I am confused about whether to achieve the result via the use of
"interfaces" (is this only a vb.net feature or is it also in vb.vanilla?)
or through the creation of a new class.
It seems to me that this is a great problem to learn about inheritance,
regardless of whether I achieve the results through classes or interfaces.
I suspect that I could inherit the VB collection class and just include
ONLY the code for the overloaded "item" method (is that correct terminology
for this situation?). I have never "inherited" anything so
I do not know what is really involved yet.
I assume that I would alter the item method (isn't item a method in
vb.vanilla)
like this:
Public Property Get HOtel(VntIndexKey as variant)
set Hotel = mcol(vntindexkey)
End Property
I am not sure if I have to declare mcol as a collection since the base
class
VBcollection already has mcol declared.
I know I have to put the following at the head of the module:
Public Class Collection
Inherits Collection
Also...i am not sure I understand the difference between "shadowing" and
overriding.
Thank you for your help.
Bil