Skip to Content
COM+ Programming with Visual Basic
book

COM+ Programming with Visual Basic

by Jose Mojica
June 2001
Intermediate to advanced
368 pages
11h 3m
English
O'Reilly Media, Inc.
Content preview from COM+ Programming with Visual Basic

Defining Interfaces in Visual Basic

What keeps us from upgrading the CAccount class is that the client has a dependency on the first version of the public members of the class. There is no problem with changing private members, since they’re completely transparent to the client, but you cannot change public members. There is a one-to-one relationship between the class itself and the public members of the class. If the public members were not part of the CAccount class, then the client would not have dependencies on the class, and the class could be changed without problems. Therefore, we must dissociate the public member declarations from their implementation. To do this, a new entity known as an interface is built. The simplest definition of an interface is that it is a class with public properties and methods but without any code. The class serves as a definition of methods, a protocol that a client will use to communicate with the class. In Chapter 3, you are going to learn a more concrete definition. However, for now it is sufficient to think of an interface as a class with declarations but without code. For example, let’s return to the CAccount class. Instead of adding public members directly to this class, let’s create a second class and call it IAccount. The IAccount class will have the following code:

' Class IAccount

Public Property Get Balance(  ) As Currency
End Property

Public Sub MakeDeposit(ByVal Amount As Currency)
End Sub

As you can see from the definition, there are ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Subclassing and Hooking with Visual Basic

Subclassing and Hooking with Visual Basic

Stephen Teilhet
VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax
Programming in the .NET Environment

Programming in the .NET Environment

Damien Watkins, Mark Hammond, Brad Abrams

Publisher Resources

ISBN: 1565928407Supplemental ContentCatalog PageErrata