Chapter 3. Putting Object-Oriented Programming to Work

Not all object-oriented programming (OOP) concepts are new to Visual Basic. The language has had support for classes and interface-based programming since Version 4, and, arguably, the drag-and-drop controls that have been central to the Visual Basic programming paradigm since Version 1 are a sterling example of what reusable objects can achieve. When you drop a Button control onto a VB 6 form, for example, you create a new instance of the control in a way that is analogous to the way a class is instantiated in a traditional object-oriented language. Likewise, when you set the Caption property of a Button or call the Show method of a form, you perform tasks that are analogous to setting a property or calling a method on an object.

Still, it’s hard to argue that VB 6 is a truly object-oriented language. It lacks support for such crucial features such as inheritance, which allows one class to derive its properties and functionality from another. Were that functionality present, for example, you would be able to create your own custom Buttons by deriving from the Button control that ships with VB 6. Interface-based programming is so difficult in VB 6 that few programmers have bothered to master it. VB 6 has no support for defining or working with interfaces, for example, and VB 6 programmers schooled in OOP principles must resort to virtual base classes to achieve the same result.

In the end, many—perhaps most—Visual Basic programmers ...

Get Visual Basic 2005 Jumpstart 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.