Visual Basic Object Support

In the early days, Visual Basic was could not be considered an object oriented language. However, starting with Visual Basic 4.0 – the first Win32 implementation – Microsoft started introducing object-oriented features. This has culminated in the latest version – Visual Basic.NET – which has all the trappings of a full object-oriented language, supporting all the purist concepts such as inheritence, polymorphism, and so on.

In between are Visual Basic versions 5.0 and 6.0, which support the basic object-oriented requirements of classes, methods, properties, etc., and allow COM-based objects to be accessed and created. These versions are the most widely used today, and are the versions around which this discussion is based.

An object is created, or exists, as an instance of a class. For example, when modelling a house, the front door and the back door could be considered instances of a door class. In Visual Basic such classes are coded within class modules, which have extension ‘.CLS’.

In a traditional Visual Basic application (Standard ‘EXE’ project) classes are Private – that is private to the project in which they are included. They can only be created and accessed within the project in which they are defined. In an ActiveX project (‘DLL’, ‘EXE’, or ‘OCX’) classes can be Public as well as Private, and can be created from other applications. The use of Public classes is the cornerstone of component development under Visual Basic.