471,852 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

Module vs Class Module

Are there any performance or memory-usage benefits of placing public
functions and subroutines in a Class Module rather than a standard
module?
Nov 20 '05 #1
4 13789
All a module is is a sealed class with all shared properties/methods etc.
I'm not sure if you are referring to 'Class Module' as in the old VBA sense
or as a Class. There is not Class Module in the VBA sense equvialent in
..NET
"Brad Parks" <br***********@yahoo.com> wrote in message
news:bf**************************@posting.google.c om...
Are there any performance or memory-usage benefits of placing public
functions and subroutines in a Class Module rather than a standard
module?

Nov 20 '05 #2
"Brad Parks" <br***********@yahoo.com> schrieb
Are there any performance or memory-usage benefits of placing
public functions and subroutines in a Class Module rather than a
standard module?


No. A Module *is* a special class:
- all members are automatically declared Shared
- no instance can be created
- it is imported automatically at project level
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Brad,

* br***********@yahoo.com (Brad Parks) scripsit:
Are there any performance or memory-usage benefits of placing public
functions and subroutines in a Class Module rather than a standard
module?


If you are referring to VB Classic (Version 1-6), please turn to one of
the microsoft.public.vb.* groups.

For VB.NET: Modules get compiled to friend classes which are imported
automatically. There are no performance and memory-using benefits when
using a class with shared methods instead.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Brad,
If by "Class Module" you are referring to a class that only has Shared
members, then as the others have stated there is no performance or
memory-usage benefits.

However! the biggest benefit I see to using classes with Shared members over
Modules is encapsulation, you are "required" to qualify the name of the
class when you use one of the shared members, ensuring that you know were
that member is coming form.

BTW: You can relax this "requirement" by importing the class itself, which
then allows it to work like a Module for that source file.

For example:
Imports System.Math

Hope this helps
Jay

"Brad Parks" <br***********@yahoo.com> wrote in message
news:bf**************************@posting.google.c om...
Are there any performance or memory-usage benefits of placing public
functions and subroutines in a Class Module rather than a standard
module?

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by dody suria wijaya | last post: by
4 posts views Thread by Edvard Majakari | last post: by
2 posts views Thread by Reid Priedhorsky | last post: by
32 posts views Thread by Matias Jansson | last post: by
13 posts views Thread by André | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.