Home All Groups Group Topic Archive Search About
Author
12 Jan 2006 5:50 AM
Laserson
Hi! I can't understand what difference between modules and classes in VB.NET
project?

Author
12 Jan 2006 6:12 AM
Cor Ligthert [MVP]
Laserson.

A module is a piece of program directly on the program stack.

An object is a piece of program placed on the managed heap.
(Another place in memory, however more flexible to use).

An object is made by instancing a Class. That means that on the program
stack is an address that tells where the created object is.

If you have read about a shared Class, than that is almost the same as a
Module. The main difference for me is, that a Shared Class gives you more
possibilitie to describe things more nice.

I hope this helps,

Cor
Author
12 Jan 2006 6:14 AM
Mattias Sjögren
>Hi! I can't understand what difference between modules and classes in VB.NET
>project?

A module is basically a class where all the members are implicitly
Shared and without any constructor so you can't create instances of
it.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
12 Jan 2006 12:05 PM
Carlos J. Quintero [VB MVP]
See:

Visual Basic Language Concepts
Classes vs. Modules
http://msdn2.microsoft.com/en-us/library/7825002w(en-US,VS.80).aspx

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio 2005, Visual Studio .NET,
VB6, VB5 and VBA
You can code, design and document much faster in VB.NET, C#, C++ or VJ#
Free resources for add-in developers:
http://www.mztools.com


Show quoteHide quote
"Laserson" <laser***@inbox.ru> escribió en el mensaje
news:%23$%23KGwzFGHA.3100@tk2msftngp13.phx.gbl...
> Hi! I can't understand what difference between modules and classes in
> VB.NET
> project?
>
>
Author
12 Jan 2006 1:00 PM
Herfried K. Wagner [MVP]
"Laserson" <laser***@inbox.ru> schrieb:
> I can't understand what difference between modules and classes in VB.NET
> project?


Classes are used to model /entities/ such as cars, customers, and pets which
can be instantiated multiple times.  Modules on the other hand are used to
/group/ functions which belong to each other, but do not form an entity
(file access functions, for example).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
12 Jan 2006 5:46 PM
David Anton
A module is really just a shorthand for a Friend, NotInheritable class with
only shared members and an implicit private constructor to avoid
instantiation.

The one wrinkle is that VB lets you access the members without qualification.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter



Show quoteHide quote
"Laserson" wrote:

> Hi! I can't understand what difference between modules and classes in VB.NET
> project?
>
>
>
Author
12 Jan 2006 6:03 PM
_AnonCoward
"David Anton" <DavidAn***@discussions.microsoft.com> wrote in message
news:BE5F746E-92B4-4039-BC4A-3899E699AD6D@microsoft.com...
:
: A module is really just a shorthand for a Friend, NotInheritable class
: with only shared members and an implicit private constructor to avoid
: instantiation.
:
: The one wrinkle is that VB lets you access the members without
: qualification.


I understood everything except that last comment. What do you mean by that?
Thanx,


Ralf
--
--
----------------------------------------------------------
*             ^~^                   ^~^                  *
*          _ {~ ~}                 {~ ~} _               *
*         /_``>*<                   >*<''_\              *
*        (\--_)++)                 (++(_--/)             *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.
Author
12 Jan 2006 8:34 PM
David Anton
If you have a module named "MyModule" with the method "MyMethod", you can
simply specify "MyMethod" elsewhere in your project - you don't need to have
"MyModule.MyMethod", which you would have to do for a shared method in a
regular class.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter



Show quoteHide quote
"_AnonCoward" wrote:

>
> "David Anton" <DavidAn***@discussions.microsoft.com> wrote in message
> news:BE5F746E-92B4-4039-BC4A-3899E699AD6D@microsoft.com...
> :
> : A module is really just a shorthand for a Friend, NotInheritable class
> : with only shared members and an implicit private constructor to avoid
> : instantiation.
> :
> : The one wrinkle is that VB lets you access the members without
> : qualification.
>
>
> I understood everything except that last comment. What do you mean by that?
> Thanx,
>
>
> Ralf
> --
> --
> ----------------------------------------------------------
> *             ^~^                   ^~^                  *
> *          _ {~ ~}                 {~ ~} _               *
> *         /_``>*<                   >*<''_\              *
> *        (\--_)++)                 (++(_--/)             *
> ----------------------------------------------------------
> There are no advanced students in Aikido - there are only
> competent beginners. There are no advanced techniques -
> only the correct application of basic principles.
>
>
>
Author
12 Jan 2006 8:44 PM
_AnonCoward
Suspected as much, but wasn't sure. Thanx for the clarification.

Ralf

Show quoteHide quote
"David Anton" <DavidAn***@discussions.microsoft.com> wrote in message
news:F7510261-42CF-4248-ACEF-B77A2AEBE395@microsoft.com...
: If you have a module named "MyModule" with the method "MyMethod", you can
: simply specify "MyMethod" elsewhere in your project - you don't need to
have
: "MyModule.MyMethod", which you would have to do for a shared method in a
: regular class.
: --
: David Anton
: www.tangiblesoftwaresolutions.com
: Instant C#: VB to C# converter
: Instant VB: C# to VB converter
: Instant C++: C# to C++ converter & VB to C++ converter
: Instant J#: VB to J# converter
:
:
:
: "_AnonCoward" wrote:
:
: >
: > "David Anton" <DavidAn***@discussions.microsoft.com> wrote in message
: > news:BE5F746E-92B4-4039-BC4A-3899E699AD6D@microsoft.com...
: > :
: > : A module is really just a shorthand for a Friend, NotInheritable class
: > : with only shared members and an implicit private constructor to avoid
: > : instantiation.
: > :
: > : The one wrinkle is that VB lets you access the members without
: > : qualification.
: >
: >
: > I understood everything except that last comment. What do you mean by
that?
: > Thanx,
: >
: >
: > Ralf
: > --
: > --
: > ----------------------------------------------------------
: > *             ^~^                   ^~^                  *
: > *          _ {~ ~}                 {~ ~} _               *
: > *         /_``>*<                   >*<''_\              *
: > *        (\--_)++)                 (++(_--/)             *
: > ----------------------------------------------------------
: > There are no advanced students in Aikido - there are only
: > competent beginners. There are no advanced techniques -
: > only the correct application of basic principles.
: >
: >
: >
Author
12 Jan 2006 7:53 PM
Mattias Sjögren
David,

>A module is really just a shorthand for a Friend,

It can be Public too.


>an implicit private constructor to avoid
>instantiation.

Or rather no constructor at all. A private ctor doesn't prevent
instantiation from within the type itself.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
12 Jan 2006 8:33 PM
David Anton
No - if you specify "Public" it still can't be accessed outside of the
project - so for modules "Public" means the same as "Friend".

(Unless Microsoft has changed this for 2005...?)

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter



Show quoteHide quote
"Mattias Sjögren" wrote:

> David,
>
> >A module is really just a shorthand for a Friend,
>
> It can be Public too.
>
>
> >an implicit private constructor to avoid
> >instantiation.
>
> Or rather no constructor at all. A private ctor doesn't prevent
> instantiation from within the type itself.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP]  mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>
Author
12 Jan 2006 8:45 PM
Mattias Sjögren
>No - if you specify "Public" it still can't be accessed outside of the
>project - so for modules "Public" means the same as "Friend".
>
>(Unless Microsoft has changed this for 2005...?)


I can use a public module from another assembly in both v7.1 and v8.0.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
12 Jan 2006 9:35 PM
David Anton
You're right - I don't know what I was thinking!
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter



Show quoteHide quote
"Mattias Sjögren" wrote:

>
> >No - if you specify "Public" it still can't be accessed outside of the
> >project - so for modules "Public" means the same as "Friend".
> >
> >(Unless Microsoft has changed this for 2005...?)
>
>
> I can use a public module from another assembly in both v7.1 and v8.0.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP]  mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>
Author
13 Jan 2006 1:37 AM
Dennis
Interesting discussion...I learn something everyday.  While reading this
string of notes, it came to me that a lot of people on this newsgroup often
recommend using a class instead of a modules  Since a module is really a
class without a constructor where public functions, subs, and variables are
shared, why the mindset against modules?
--
Dennis in Houston


Show quoteHide quote
"David Anton" wrote:

> You're right - I don't know what I was thinking!
> --
> David Anton
> www.tangiblesoftwaresolutions.com
> Instant C#: VB to C# converter
> Instant VB: C# to VB converter
> Instant C++: C# to C++ converter & VB to C++ converter
> Instant J#: VB to J# converter
>
>
>
> "Mattias Sjögren" wrote:
>
> >
> > >No - if you specify "Public" it still can't be accessed outside of the
> > >project - so for modules "Public" means the same as "Friend".
> > >
> > >(Unless Microsoft has changed this for 2005...?)
> >
> >
> > I can use a public module from another assembly in both v7.1 and v8.0.
> >
> >
> > Mattias
> >
> > --
> > Mattias Sjögren [C# MVP]  mattias @ mvps.org
> > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > Please reply only to the newsgroup.
> >
Author
13 Jan 2006 4:48 AM
David Anton
Others can outline the other reasons, but personally I don't like the way
that modules hide their special characteristics.  This leads programmers to
code by rote without understanding fully what they're doing.  I realize that
many VB programmers do know what they are doing when they code a module, but
many don't and anything that encourages ignorance can cause problems down the
road.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter



Show quoteHide quote
"Dennis" wrote:

> Interesting discussion...I learn something everyday.  While reading this
> string of notes, it came to me that a lot of people on this newsgroup often
> recommend using a class instead of a modules  Since a module is really a
> class without a constructor where public functions, subs, and variables are
> shared, why the mindset against modules?
> --
> Dennis in Houston
>
>
> "David Anton" wrote:
>
> > You're right - I don't know what I was thinking!
> > --
> > David Anton
> > www.tangiblesoftwaresolutions.com
> > Instant C#: VB to C# converter
> > Instant VB: C# to VB converter
> > Instant C++: C# to C++ converter & VB to C++ converter
> > Instant J#: VB to J# converter
> >
> >
> >
> > "Mattias Sjögren" wrote:
> >
> > >
> > > >No - if you specify "Public" it still can't be accessed outside of the
> > > >project - so for modules "Public" means the same as "Friend".
> > > >
> > > >(Unless Microsoft has changed this for 2005...?)
> > >
> > >
> > > I can use a public module from another assembly in both v7.1 and v8.0.
> > >
> > >
> > > Mattias
> > >
> > > --
> > > Mattias Sjögren [C# MVP]  mattias @ mvps.org
> > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > > Please reply only to the newsgroup.
> > >
Author
13 Jan 2006 7:10 AM
Cor Ligthert [MVP]
Dennis,

> Interesting discussion...I learn something everyday.  While reading this
> string of notes, it came to me that a lot of people on this newsgroup
> often
> recommend using a class instead of a modules  Since a module is really a
> class without a constructor where public functions, subs, and variables
> are
> shared, why the mindset against modules?
> --

For me is it the one as David wrote.
>The one wrinkle is that VB lets you access the members without
>qualification

If you use modules, than in a large project you don't know where the
variable/object is placed.

It can be in your method, it can be globaly in your own class, it can be in
a module.

The first to are rather quick to find in those cases that you don't use a
module (and don't set the global variables between the methods however
always on the same place).  It is in your method or globaly in your class.

If you use a module than you have to search in every module that you use as
well.

I hope that this gives an idea?

Cor