VB/VBA is not a full Object-oriented language, it does not support
Inheritance, as full Object-Oriented languages do, like C++, Java, C#,
VB.NET...
So, you cannot derive a new class ona base class. That is, you cannot first
create a "Person" class, and then derive an "Employee" class on top of it.
In VB/VBA, you only have limited Inheritance capability: Implements another
class: you define a class with properties and methods (usually, there is no
code inside the properties and methods' definitions), and define a class
that implement that interface class. A class can inmplement one or more
other classes according to your need.
Note, "Implements" a class is different from "Derive" from a base class. In
true Object-oriented language, when you subclass from a base class, it
automatically gets all proerties/methods the base class has. With
"Implements", you must write code to implement all exposed property and
method definitions in the interface class (hence the word "Implements"),
which is basically the same when you implements Interfaces in Java, C++,
C#....
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Now I have another Question.
>
> Lets say I have a class "Person" with the attributes "firstName" and
> "lastName". This class has a method "print" which will return the
> first and last name as a string.
> Now I create a class "Employee" which implements "Person" and has an
> additional attribute "salary". Now i also want to create a "print"
> method for "Employee" but i dont want to do it like this:
>
> public function print() {
> print = Me.firstName & Me.lastName & Me.salary
> }
>
> instead i would like to do it like this:
>
> public function print() {
> print = super.print() & Me.salary
> }
>
> super is supposed to call the print method from the "Person" class,
> since "Employee" implements "Person". However in vba i don't know how
> to do this, because super doesnt work in vba. Whats the way to do this
> in vba?
>
>
|