Solved

Class module

Posted on 1998-10-16
2
271 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

808 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