Review

I made the point at the beginning of the chapter that interface-based programming provides us with a mechanism to upgrade classes. To use interface-based programming, you must first define an interface in the server code. We refer to the entity that provides the class or interface definition as the server. (Do not worry at this time about how the server is packaged—you will learn more about that in later chapters.) To define an interface, you must add a class to your project and add public properties and methods (subroutines or functions) without any code. Remember that the interface is not meant to be a creatable class; it is only meant to provide the definition of functions. This is why it is a good idea to mark its instancing property as PublicNotCreatable.

Once you have defined the interface, you must implement it in a class. To do so, you simply create a new class and use the Implements statement. Once you have used the Implements statement, the code window will list the interface class as an object in the object drop-down list. Select it and then select each function of the interface in the function list drop-down. Once you have added each property and function in the interface to your implementation class, then you write code for each of the methods of the interface. This is all that needs to be done by the server.

To use the implementation class through the interface definition, you declare a variable of the interface type, then set the variable to a new instance of ...

Get COM+ Programming with Visual Basic 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.