Solved

Class module

Posted on 1998-10-16
2
270 Views
Last Modified: 2013-11-23
I may seem like a dumby but what is different about a class module from a normal module?
0
Comment
Question by:goodbye11
2 Comments
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1440332
As far as what you can do, functionaly, there isn't any difference.  What a class allows you to do is encapsulate the function of an 'object'.  What it allows you to do is create an object, with properties, that you can control what happens.  It is real hard to describe.  A recent thing that I did was create my own Errors Collection.  When you have an error, you just added it to the collection.  All you do is invoke the Add method of the collection.  Say you want to log these errors to a file, the calling program doesn't know this.  The calling program sets a property saying it wants to log the function.  Then it just calls the method on the object, without real knowing what goes on the the object.  You change the object to do what you want to do, and keep the GUID the same (how you reference a program for another program) and all you have to do is re-install the class component, and not the whole application.  The other thing you can do with a group of objects is define the same functions to each object.  One program doesn't care what sort of object it is, it just knows it has an object and needs to invoke a standard method on that object.  Basically, it boils down to this, an object is supposed to understand how to deal with itself.  When it changes, it knows whether you update a database, whether the values are valid, etc.  The program using the object doesn't have to know this, it only has to know when things aren't right.  The object tells it that.  So, when you use this object, the program using it knows it is going to take care of itself.  

I hope this helps,
Martin
0
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 10 total points
ID: 1440333
To understand when to use a class module, it is important to realize the differences between standard modules and class modules. The primary difference is how
data is stored. In a standard module, if one section of your program changes a public variable of the module and another section of your program then reads that
variable, the new value is returned. Consider the following items when determining whether to use a class module or a standard module:

     How data is used--Data can exist independently for each instance of the class.

     Required lifetime code--Data exists in a standard module for the entire life of your program, whereas data in a class module only exists for the lifetime of the
     object that is instantiated from the class.

     Where is code called--Class modules should be used any time your program requires multiple instances of code or data.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add a task in Outlook from access 11 39
Delphi Yen format 3 33
vbModal 12 51
VBA: copy range dynamically based on config sheet v2 3 31
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question