Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This is easily the most helpful website I've ever used, and this is the best forum with the quickest response time bar none...."

Geography

Where in the world do Tek-Tips members come from?
RebelFox (Programmer)
29 Oct 03 9:25
Can somebody explain to me the difference between a class and a module in a VB project?
RoguePoet01 (Programmer)
29 Oct 03 17:48
I'm not very informed about classes at all, but I think that a class is sort of like a specialized group of code.  For forms, buttons, textboxes...I think...are all basically classes.

Modules are, for me, just ways to break up code in more managable sections.  For instance, I might have a module that just dealt with updates, and another that dealt with adds.  It could all be in the same module, but breaking it up makes it easier to follow.

Though I, too, would like to hear what others have to say.
zemp (Programmer)
30 Oct 03 8:03
I believe that Classes are objects where the code is self contained. They usually do a specific job well and are designed to be easily reused without changing the code. The object needs to be properly created and qualified when used.

A module is a way to share variables, functions and procedures throughout an application. A way to use global scope.

Take Care,

zemp

"Show me someone with both feet on the ground and I will show you someone who can't put their pants on."

pweegar (Programmer)
30 Oct 03 10:38
A class is the core of Object Oriented Programming. They are very similiar to a Structure in C++ programming.

A module will contain variables, functions as well as classes.
LazyMe (Programmer)
31 Oct 03 6:54
>>They are very similiar to a Structure in C++ programming.

No they are not. Apart from the fact that they can contain public and private vars and methods and can be instantiated multiple times, they're far from what a C++ Class or Struct can do. And they also have something a C++ Class or Struct cannot do: they can generate events.

Actually the difference is very simple:
A class is some encapsulated piece of code, as well as a module can be. Both can contain private- as well as public vars and methods.

However, a module can be accesed without having to instiate it, it's always there; no matter in which part of your app you are; you can always access it's vars and methods (provided that they're public, of course.....).
A class needs to be instantiated first. You cannot use anything unless you have created an instance of it.
And this leads to the main difference of them (apart from classes having constructors/destructors and being able to generate events): There's never no more than ONE "instance" of your module; only one instance of its vars. Whereas you can have as many instances of a particular class as you wish; so as many instances as its vars as well....

Greetings,  
Rick

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close