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

Hi all,
  I've seen a number of code samples where the developer puts the
majority of their code into a regular code module and then have their
UserControl (Form, Class) call into that module.  
  Does anyone know if there is there any benefit to programming this
way?  I haven't seen any documentation indicating pro/cons for it.
Currently I am putting all the code into its related UserControl.
  Is there some memory/performance issue around this?

TIA!

--
Chris



Fri, 01 Sep 2000 03:00:00 GMT  
 Q: Code Module vs UserControl (Form, Class) module.


Fri, 19 Jun 1992 00:00:00 GMT  
 Q: Code Module vs UserControl (Form, Class) module.

Christopher an obvious benefit is the ability to create reusable code
components.
An example of this is input validation.  You can create one common module
and call the common code from the particular controls.  This results in a
smaller
application size and reusable code components.



Quote:
> Hi all,
>   I've seen a number of code samples where the developer puts the
> majority of their code into a regular code module and then have their
> UserControl (Form, Class) call into that module.  
>   Does anyone know if there is there any benefit to programming this
> way?  I haven't seen any documentation indicating pro/cons for it.
> Currently I am putting all the code into its related UserControl.
>   Is there some memory/performance issue around this?

> TIA!

> --
> Chris



Fri, 01 Sep 2000 03:00:00 GMT  
 Q: Code Module vs UserControl (Form, Class) module.

Also, although controls can be instantiated multiple times, modules don't.
Therefore, you can place many instances of the same control (or controls
from the same .OCX) that all rely on the same set of routines (instead of
separate instances).

Just my two bits.
--
R. Aaron Zupancic
MCT Visual Basic, Access

http://home.utah-inter.net/azupancic



Quote:
> Christopher an obvious benefit is the ability to create reusable code
> components.
> An example of this is input validation.  You can create one common module
> and call the common code from the particular controls.  This results in a
> smaller
> application size and reusable code components.



> > Hi all,
> >   I've seen a number of code samples where the developer puts the
> > majority of their code into a regular code module and then have their
> > UserControl (Form, Class) call into that module.  
> >   Does anyone know if there is there any benefit to programming this
> > way?  I haven't seen any documentation indicating pro/cons for it.
> > Currently I am putting all the code into its related UserControl.
> >   Is there some memory/performance issue around this?

> > TIA!

> > --
> > Chris



Fri, 01 Sep 2000 03:00:00 GMT  
 Q: Code Module vs UserControl (Form, Class) module.

Hi Aaron:

Quote:
>Also, although controls can be instantiated multiple times, modules don't.
>Therefore, you can place many instances of the same control (or controls
>from the same .OCX) that all rely on the same set of routines (instead of
>separate instances).

Even instances of the same control will use the *same* code segment (whether
that code is in the control or the bas module); the difference between the
two is that Windows will automatically discard,move, and load/unload the
code in a bas module if it needs the memory -- the code in the control does
not get discarded until the control is unloaded.

Doug.



Fri, 01 Sep 2000 03:00:00 GMT  
 Q: Code Module vs UserControl (Form, Class) module.

Typically, you are correct. One should try to incapsulate as much as
possible.
However, there are two advanatages to using std code modules.

1) Should you require global data, you can only put it in a std code module.
This allows you, for example, to have many controls access the same database
connection.
In essence, this is a common way to have data exposed which is "sharable" by
multiple instances of classes or controls.

2) This also gives you a convenient way to handle callback functions. The
AddressOf operator will only work with functions specified in std code
modules. This is kind of a safety-net since the address of global functions
don't change as long as the DLL's image is valid.

-Rob


Quote:
>Hi all,
>  I've seen a number of code samples where the developer puts the
>majority of their code into a regular code module and then have their
>UserControl (Form, Class) call into that module.
>  Does anyone know if there is there any benefit to programming this
>way?  I haven't seen any documentation indicating pro/cons for it.
>Currently I am putting all the code into its related UserControl.
>  Is there some memory/performance issue around this?

>TIA!

>--
>Chris



Fri, 01 Sep 2000 03:00:00 GMT  
 Q: Code Module vs UserControl (Form, Class) module.

I had the same question, but I would like to know more specifically about
performance issues. Would I incur a big performance loss in using
UserControls instead of classes?

--
****************************************************************************
Mohammed AlQuraishi
SiteBuilder Level 2
ClubIE Team 4
Independent Microsoft Beta Tester
TechWeb/Microsoft 2nd Place ActiveX Contest Winner (Business)
http://www.advancednetsolutions.com

"It is the bias of our society that creates the smart and the stupid." a
*Smart* guy.
"To war is not only to win, it's also to fight."
****************************************************************************

Quote:
>Hi all,
>  I've seen a number of code samples where the developer puts the
>majority of their code into a regular code module and then have their
>UserControl (Form, Class) call into that module.
>  Does anyone know if there is there any benefit to programming this
>way?  I haven't seen any documentation indicating pro/cons for it.
>Currently I am putting all the code into its related UserControl.
>  Is there some memory/performance issue around this?

>TIA!

>--
>Chris



Fri, 01 Sep 2000 03:00:00 GMT  
 Q: Code Module vs UserControl (Form, Class) module.

Mohammed

Yours is rather a different question. There's no comparison between
OCX's and classes. You write an OCX if you want something to act as a
control at design time. Classes are a way of designing code.

There are performance issues with any approach. Classes are inclined to
perform slightly less well than 'conventional' code but make it vastly
more maintainable (if designed correctly).

Regards
{*filter*}

Quote:

>I had the same question, but I would like to know more specifically
about
>performance issues. Would I incur a big performance loss in using
>UserControls instead of classes?

>--
>***********************************************************************
*****
>Mohammed AlQuraishi
>SiteBuilder Level 2
>ClubIE Team 4
>Independent Microsoft Beta Tester
>TechWeb/Microsoft 2nd Place ActiveX Contest Winner (Business)
> http://www.*-*-*.com/

>"It is the bias of our society that creates the smart and the stupid."
a
>*Smart* guy.
>"To war is not only to win, it's also to fight."
>***********************************************************************
*****


>>Hi all,
>>  I've seen a number of code samples where the developer puts the
>>majority of their code into a regular code module and then have their
>>UserControl (Form, Class) call into that module.
>>  Does anyone know if there is there any benefit to programming this
>>way?  I haven't seen any documentation indicating pro/cons for it.
>>Currently I am putting all the code into its related UserControl.
>>  Is there some memory/performance issue around this?

>>TIA!

>>--
>>Chris



Sat, 02 Sep 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

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

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

3. class module vs. module

4. Class Module vs Module

5. Class Module vs. REgular Module

6. Modules vs. Class Modules

7. Module code vs. Form code

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

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

10. Visual Basic Activex Interaction Usercontrol / Class Module

11. Access constituent controls of a UserControl from a Class module

12. UserControl reference in a class or .bas module

 

 
Powered by phpBB® Forum Software