There's no simple answer, but a class is something like a cross between a
user-defined type (a structure) and a regular module, but with the added
feature that the object variables don't contain the structures, but hold
pointers to them, and VB keeps track of how many pointers to the structure
exist at any given time, and automatically destroys the object when no more
pointers remain (so nothing can possibly be using it anymore), and frees up
the memory it was using.
The bottom line things you're usually trying to do with class modules are...
1. Keep the code and its variables together in one place.
2. Engineer out memory leaks by having objects released automatically when
they're no longer being used.
In VB, class modules are also required to send and receive events.
When working in VB, you are actually using classes all the time, even if
you're not making your own. A Recordset is a great example. Each recordset
is the same type of thing - they are all recordsets, and they are all managed
by the same code, but each recordset is distinct from all the others, each
with its own data and state. If you set one Recordset variable equal to
another, you still have just one recordset, but with 2 variables pointing to
it, etc. When you make your own class modules, you can do all the same types
of things.
On Tue, 11 May 2004 16:24:01 +1200, "WindAndWav es" <ac****@ngaru.c om> wrote:
Hi Everyone
I am getting more and more interested in the art of programming and I have
noticed that some people use class modules.
Can you tell me what the use is of these things???
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.679 / Virus Database: 441 - Release Date: 07/05/2004