What is the benifit to programming w/ Class Modules

O

Office_Novice

Greetings,
I am a novice trying to fully or at least partially understand the
benifits to Class Modules. After looking through a ton of stuff on the
internet i find myself even more confused. Seems like an awful lot of typing
for little result. What am i missing?
 
N

Nobody

Office_Novice said:
Greetings,
I am a novice trying to fully or at least partially understand the
benifits to Class Modules. After looking through a ton of stuff on the
internet i find myself even more confused. Seems like an awful lot of
typing
for little result. What am i missing?

Some links for you:

http://msdn.microsoft.com/en-us/library/aa141681(office.10).aspx

http://puremis.net/excel/code/086.shtml

http://exceltip.com/st/Class_modules_using_VBA_in_Microsoft_Excel/510.html
 
C

Chip Pearson

I have an introduction to classes on my web site at
http://www.cpearson.com/excel/Classes.aspx. A class module is used to
present an abstraction of anything you need to work with in your
program. For example, for a office productivity application, you need
to deal with people. You would create a class named CPerson, give it
properties (which are like adjectives -- they describe attributes such
as Name, Address, Salary) and give it methods (which are like verbs --
they carry out actions, like PrintPaycheck). Once you have a class,
you create instances of the class called object (Dim Pawn As CPerson,
Dim Boss As CPerson) and you can pass those objects around within an
application, and the code that uses them need not know the internals
of how a class is implemented. The code can simply examine the
appropriate properties or carry out the various methods while being
peacefully oblivious to all else that makes up the class.

If you programmed with structures (also called structs or records), a
class is like a structure except that it executes code in addition to
simply storing data value in an organized way.


Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
The San Diego Project Group, LLC
(email is on the web site)
USA Central Daylight Time (-5:00 GMT)
 
O

Office_Novice

Thanks for the reply Chip,
I spend an awful lot of time on your site and have seen the introduction to
classes. So using your example would I have to create a new class for each
person, or just one for everybody?
 
B

Bob Phillips

You would create one class instance for every person (Set Person = New
cPerson). It would be useful to group the people into a collection class,
which gives you the ability to iterates through every member (person) of
that class.
 
Top