Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Class module

Posted on 1998-10-16
2
Medium Priority
?
275 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 20 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

926 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