At 11:01 AM -0500 3/3/06, Ian R wrote:
Define a new Class Interface, called Loadable, that defines a Load
method. Make each of your control subclasses implement this
interface (which, since they already have a Load method, simply
means adding "Loadable" to their Interfaces property). Then the
code in your superclass becomes:
if control(i) IsA Loadable then Loadable(control(i)).Load
Ok. That's what Guyren said, also, I think. I thought it was more
of a code cleanliness thing, but if that's what I actually need to
do to make this work, then I'm all over it.
Well, it's not the only way to do it; you could also test against
each control subclass, and then typecast to that subclass.
But the interface is better since it requires less code, and if you
ever make another control subclass that also implements the Load
interface, then it will automatically get called.
This is what makes interfaces so cool: you have a bunch of classes
that you know all do something, but you don't want to have to worry
about WHICH class you're dealing with everywhere you need to do that
something. So you have all those classes implement an interface
which defines that something, and presto! You no longer care what
class it is; you can simply test whether it does that something, and
if so, tell it to do it. It's like magic!
Best,
- Joe
--
Joseph J. Strout
[EMAIL PROTECTED]
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>