Tuesday, 20 December 2011

“Implements” Keyword, Interface – Class in VBA

Recently I was puzzled with a question about the levels of Object oriented structure can VBA support?
Suddenly my thoughts shifted to the key word I was always suspicious about but didn’t found time to explore. This post is all about key word “Implements” in VBA.

Learning about “Implements” in the context of VBA I am quite amazed about its potential. This keyword is used in conjunction to provide the interface-class implementation structure to VBA.
The code in the attached file is separated into 3 class objects (out of which 2 are implementation of the 1 interface) and 1 module object to illustrate the usage.

Code Explanation:
The attached file along with this post creates the following VBA structure:
1. IHuman (Interface)
2. clsMan (Class implementing IHuman)
3. clsWomen (Class implementing IHuman)
4. modTest (Module illustrating the usage of the class/interface)

The code also illustrates the additional method defined in the implementing classes and their usage patterns. Please explore the attached file VBA for the entire code.

Download:

Download Solution
Download solution


Refrences:
Link: http://www.vbi.org/Items/article.asp?id=78

1 comment:

Unknown said...

Hi, can it be used to implement external interfaces? -thx!