reddarin,
BTW, this is a very expansive topic; wait for some other Experts more versed in class modules to share their thoughts
before accepting this answer.
Regards,
Patrick
Main Topics
Browse All TopicsWhat is the difference between a Class Module and a Module? Specifically, what is the advantage of one over the other?
reddarin
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks, I will keep it open for a bit but you have answered my question I think. I have used Excel and VBA before and I created a very cool expense report with lots of VBA code but it was a long, long time ago so mostly I need refresher information.
I have a list of people with various attributes - start time (as in punch-in and go to work), truck number, washout time, punch-out time, etc. That would seem to be a perfect situation for a class module, wouldn't it?
The thing is, each person may or may not be assigned to a truck and their assigned truck may change from day to day. But, the truck is really the key element in the operations of the plant.
So, maybe I am looking at that from the wrong direction? I could view it as the truck having a punch in time, a washout time and a punch out time. Sometimes, the truck is down so it would have none of those values and correspondingly the person that usually drives it would be unassigned.
Perhaps a truck value of 'Extra' would take care of unassigned drivers?
reddarin
reddarin,
as Patrick lined out, the class module is VBA's attempt to object orientation (oo), whereas it is a oppr man's oo, the oo-cracks like to call VBA (or VB6) rather object based. The VBA class concept is missing some very important concepts:
- First of all the inheritance feature, which make it neearly impossible to build larger object hierarchies.
- Second the bad implementation if the constructor methods, whic cannot be invoked wit any argumens
If you know the old "Type" statement, to create complex datat types, the Clas smodules can be looked upon as types with methods, i.e. procedures and functions that work on and with the different attributes af the class members.
In your case, it could be an idea to implement, Truck, Driver and Tour. For each tour you have a truck and a driver. But this depends on the requirements on your data model.
Xanius
Some good explanation between classes and modules can be found on:
http://www.exceltip.com/st
regards,
Jeroen
Business Accounts
Answer for Membership
by: matthewspatrickPosted on 2006-02-25 at 06:30:43ID: 16045358
Hi reddarin,
A class module is typically used to either:
1) Create your own classes (essentially custom objects), along with properties and methods to go along with those new objects or
2) Trap events for certain Excel objects that do not by default have their own class modules, such as the Application object or
a ChartObject (which is an embedded chart on a sheet, and is not to be confused with a Chart, which is a chart that is a sheet
unto itself).
The SheetN, ThisWorkbook, and UserForm (if any) modules are class modules themselves; they are bound to the various sheets,
the workbook, and the UserForms respectively and cannot be added or removed except by adding or removing the objects
themselves. (Obviously, ThisWorkbook is always there :)
Regular modules are for code related to everything else.
Regards,
Patrick