Implements Statement

Named Arguments

No

Syntax

Implements objVarName

objVarName

Use: Required

Type: Class

The name of an object variable referencing a standard interface class.

Description

The Implements statement allows you to provide polymorphism within your object models. Polymorphism has the advantages of speed and flexibility over inheritance—though, unfortunately, we have neither the time nor space to explore these concepts in depth here. Polymorphism boils down to a set of guidelines or a framework the user works within to create a different end result (or implementation). Polymorphism is seen most obviously in nature. For example, a structure we all know well is a tree; its model states that it has a trunk, leaves, branches, and roots. An oak tree is one implementation of the tree "model," whereas a pine is a very different implementation of the same basic model. In Visual Basic, polymorphism is provided by standard interface (or abstract) classes and the Implements statement. The Implements statement informs VB that you are going to provide implementations for each of the Public methods and properties found in the referenced standard interface class.

The basic concept of standard interface classes is that it's the user of the class—not the interface class itself—that decides how a particular method or property should be implemented. For example, you could create a standard interface class that acts as a wrapper for a collection object. The standard interface could ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.