By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

add module vs add class??

P: n/a
Ray
Greeting,
I'm still grasping the class concept so bear with me.
I have a vb.net app in which I wrote and placed various public functions for later reference.

In vb.net there is an option to "add class" or "add module". My understanding is a module is a class so what is the difference?

Correct me if I'm wrong....a module allows you to call various functions/procedures without first defining and class you do?
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
A module is a class, it's just a sealed (ie, you can't inherit from it) and
it has shared/static members. You can create a class that gives you the
same functionality (in C# modules as such don't exist) so the distinction
isn't really there. If you have a class with all shared members, you never
instantiate it so everything is shared or static. Very handy for some apps,
not quite so useful in others.

If you want to see what's really happening, create a class that's sealed and
mark everything static. Then create a module with the same names. Compile
and look at them through ILDASM...the similarities are remarkable.

HTH,

Bill
"Ray" <an*******@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
Greeting,
I'm still grasping the class concept so bear with me.
I have a vb.net app in which I wrote and placed various public functions for later reference.
In vb.net there is an option to "add class" or "add module". My understanding is a module is a class so what is the difference?
Correct me if I'm wrong....a module allows you to call various

functions/procedures without first defining and class you do?
Jul 21 '05 #2

P: n/a
Ray
Thanks for the Reply William.

So it seems that in most cases, one would use add class as oppose to add module.

I'm slowly grasping the concept. From reading other threads there's no performance degregation in using a class vs module.

Since modules don't exist in C#, obviously use class.
But what scenario would I use module in VB as oppose to a Class?

Thanks for educating me!
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.