Functions vs Class module 
Author Message
 Functions vs Class module

I have a very short sw-career, so this may be a so called newbie question:
When shall I use class module with Get and Let,  instead of sub
procedures/functions in a module??
I have some books, and I have used MSDN, but still don't understand when it
is reasonable to use a class insted of functions in a module.

Please give me an example.

best regs. ocm

Sat, 26 Jul 2003 18:10:23 GMT  
 Functions vs Class module
From my experience, you want to use a class module when you want to create
multiple seperate instances of the object, which each have their own data.
An example my be a class module for building SQL statements. You could have
methods for adding clauses (right term?) to the statement, and a property
get to retrive the whole statement. To use it you would create an instance
of the class whenever you wanted to build a statement, and then destroy it
when finished. If this had been implemented in a standard module, then you
could only create one SQL statement at a time, and you would have to
remember to reset the module when finished.

You should use a module when you want to functions that are globally
accesible throughout the project, and don't need data to persist between
different calls. An example for this might be a routine that formats a form,
making different types of controls different colours. This would be called
in the form_load event, with a reference passed to the form as an argument.

Hope this helps,

Chris Key

Sat, 26 Jul 2003 18:35:59 GMT  
 [ 2 post ] 

 Relevant Pages 

1. class module vs. module

2. Q: Code Module vs UserControl (Form, Class) module.

3. Class Module vs Module

4. Q: Code Module vs UserControl (Form, Class) module.

5. Class Module vs. REgular Module

6. Q: Code Module vs UserControl (Form, Class) module.

7. Modules vs. Class Modules

8. Class modules 97 - Refering to array within a custom class module

9. Accessing procedures of a class module from another class module

10. Class vs Module

11. Classes vs Modules

12. Module vs Class


Powered by phpBB® Forum Software