Solved

Class module

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

708 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

20 Experts available now in Live!

Get 1:1 Help Now