Skip to Content
VB & VBA in a Nutshell: The Language
book

VB & VBA in a Nutshell: The Language

by Paul Lomax
October 1998
Intermediate to advanced
656 pages
16h 10m
English
O'Reilly Media, Inc.
Content preview from VB & VBA in a Nutshell: The Language

Chapter 4. Class Modules

To some degree, class modules can be seen as "replacements" for code modules—that is, class modules are repositories for shared variables as well as for shared code, just as code modules are. So why have class modules? What's wrong with normal code modules? Basically, there is nothing wrong with them. But code modules allow you to share procedures only within the project in which they reside. For example, you can call a public function from another code module in a project, but you can't call that function from another project. To do that, you have to add the code module to your project or, even worse, create a second copy of the code module.

Class modules have (without wanting to sound too evangelistic) revolutionized VB. The whole style of writing VB programs has changed since version 4.0 of VB was launched, bringing the VB/VBA language closer than ever to being a true object-oriented language. In fact, much of VB's current success in the corporate marketplace can be directly attributed to the ability to create ActiveX components, the cornerstone of which is the class module.

When you create a class module, you are creating a COM interface. Therefore, class modules allow you to describe your application to the outside world via a programmable interface that consists of properties, methods, and events in a way that allows you to retain control over the application. Using class modules, you can break an application into logical sections, each having its ...

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

Absolute Beginner's Guide to VBA

Absolute Beginner's Guide to VBA

Paul McFedries
Visual Basic 2015 Unleashed

Visual Basic 2015 Unleashed

Alessandro Del Sole

Publisher Resources

ISBN: 1565923588Catalog PageErrata