-
Book Overview & Buying
-
Table Of Contents
Visual Basic Quickstart Guide
By :
In VB, interfaces work similarly to other OOP languages. An interface in VB defines a contract that specifies a set of method signatures that classes must implement. By implementing an interface, a class agrees to provide concrete implementations for all the methods declared in the interface.
Next, we will see how to define and use interfaces in VB.
To create an interface in VB, you can use the Interface keyword, followed by the interface’s name:
Public Interface IShape Sub Draw() Function GetArea() As Double End Interface
In this example, we defined an IShape interface with two methods: Draw and GetArea. These methods are declared but not implemented in the interface; their implementation will be provided by the classes that implement this interface.
To implement an interface, a class must use the Implements keyword, followed by the interface...