Simply, a Class module serves as the "cookie cutter" of an object.
Example: behind the scenes, Excel has class modules for Workbook, Worksheet,
Range, Chart, etc. objects. Every time you reference any property or method
of those objects, their Class modules determine how Excel responds/behaves
(i.e., return or set a value, do something else).
One reason to create your own Class module would be if you wanted to create
an object with it's own Properties and Methods. Say a class for Customer,
Account, OrderItem, Transaction, Employee, Task, etc. An object is a data
structure that can be held in memory and can be easily manipulated and will
behave according to your pre-determined business rules and instructions:
Customer.Address, Transaction.Date, Employee.Age, OrderItem.Price,
Customer.UpdateBalance, Customer.AvailableCredit etc.
If something is going to be subject to a lot of processing (and/or you have
a lot of 'somethings'), loading info into a class object, putting that
object into a collection and then doing your processing can be a lot faster
and efficient than repeatedly reading & writing data to a spreadsheet.
And, aside from application-specific issues like Input & Output, a given
Customer class will behave the same in Excel or Access, so re-use and
portability can be an advantage as well.
All in all, this might come under the heading of: if you need it, you'll
know it. :-)
Microsoft Office XP Developer's Guide: Chapter 11: Custom Classes and
Objects
http://msdn.microsoft.com/library/de...sesobjects.asp
VBA Developers Handbook: Chapter 6: Creating Dynamic Data Structures Using
Class Modules
http://msdn.microsoft.com/library/de...smod ules.asp
HTH,
--
George Nicholson
Remove 'Junk' from return address.
"DCSwearingen"
wrote in message
news:DCSwearingen.21leca_1137188104.8586@excelforu m-nospam.com...
I have gone to the VBA help files to try to find the difference and I am
no better now than before.
A Class Module:
A module that contains the definition of a class, including its
property and method definitions.
A Standard Module:
A module containing only procedure, type, and data declarations and
definitions. Module-level declarations and definitions in a standard
module are Public by default. A standard module is referred to as a
code module in earlier versions of Visual Basic.
What is the purpose of a class module and when should it be created?
--
DCSwearingen
------------------------------------------------------------------------
DCSwearingen's Profile:
http://www.excelforum.com/member.php...o&userid=21506
View this thread: http://www.excelforum.com/showthread...hreadid=501243