VB Classes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Turner

    VB Classes

    Hi all,
    I have 3 questions regarding classes.
    1:- If I have a class, Class1, how do I get Class2 to inherit class1?
    2:- Assuming that the above is possible, if Class1 contains a function,
    Funct1, what scope keyword do I need so that Funct1 is only visible
    to derived classes?
    3:- Can the same be done with constants and varibles?

    Thanks for any input.

    GST


  • Dikkie Dik

    #2
    Re: VB Classes

    An alternative (just for the record, it is not the easiest one, although
    it may prevent some code duplication) is using events.

    An example:
    Say you have a superclass called "DataStorag e", which has an abstract
    method "StoreStrin g". A subclass "DatabaseStorag e" would store the
    string in a database.

    In VB6, there's a kind of "upside down" form of inheritance with events.
    You can create an instance of the DatabaseStorage class and feed it an
    instance of the "superclass " DataStorage. This instance is internally
    stored with the "Withevents " keyword. If the "StoreStrin g" method of the
    "superclass " just raises an event, the "subclass" instance containing
    it will handle the storage action.

    Best regards

    Comment

    Working...