Solved

Class module

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

919 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now