Parent property of custom class
I have a custom class and one of its properties is another custom
class
Specifically I have a class which interfaces to an external
application to grab data, and a generic sub-class which works out
statistics.
pseudo-code...
set V = new clsCalItem
V.Stats.reset
while not finshed
V.stats.add
wend
msgbox V.stats.count, v.stats.mean
and clsCalItem contains the line
dim Stats as clsStats
My problem is that to get the current numerical value of V I would use
V.Value, but I can't see how to access the .Value method of V with
code inside clsStats.
What I want is basically to be able to use, inside the clsStats code a
line something like:
internalSum = internalSum + Me.Parent.Value
There is a very simple way round this, of course, I can change the
V.Stats.Add line to be V.Stats.Add(V.Value) but I would prefer the
elegance of the first version, and I am rather intrigued about whether
it is possible now. I can see myself wanting to write a .Parent
property in the future in situations where there isn't this
workaround. Surely classes often need to know who or what they are a
subclass of?
|