473,395 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Module and Class

Hi! I can't understand what difference between modules and classes in VB.NET
project?
Jan 12 '06 #1
15 7568
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
Jan 12 '06 #2
>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.
Jan 12 '06 #3
See:

Visual Basic Language Concepts
Classes vs. Modules
http://msdn2.microsoft.com/en-us/lib...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
"Laserson" <la******@inbox.ru> escribió en el mensaje
news:%2******************@tk2msftngp13.phx.gbl...
Hi! I can't understand what difference between modules and classes in
VB.NET
project?

Jan 12 '06 #4
"Laserson" <la******@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/>

Jan 12 '06 #5
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

"Laserson" wrote:
Hi! I can't understand what difference between modules and classes in VB.NET
project?

Jan 12 '06 #6

"David Anton" <Da********@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.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.
Jan 12 '06 #7
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.
Jan 12 '06 #8
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

"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.

Jan 12 '06 #9
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" <Da********@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.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.

Jan 12 '06 #10
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.
Jan 12 '06 #11
Suspected as much, but wasn't sure. Thanx for the clarification.

Ralf

"David Anton" <Da********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.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" <Da********@discussions.microsoft.com> wrote in message
: > news:BE**********************************@microsof t.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.
: >
: >
: >
Jan 12 '06 #12
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.

Jan 12 '06 #13
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.

Jan 13 '06 #14
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

"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.

Jan 13 '06 #15
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
Jan 13 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
5
by: dody suria wijaya | last post by:
I found this problem when trying to split a module into two. Here's an example: ============== #Module a (a.py): from b import * class Main: pass ============== ==============
4
by: Edvard Majakari | last post by:
Greetings, fellow Pythonistas! I'm about to create three modules. As an avid TDD fan I'd like to create typical 'use-cases' for each of these modules. One of them is rather large, and I wondered...
2
by: Reid Priedhorsky | last post by:
Dear group, I'd have a class defined in one module, which descends from another class defined in a different module. I'd like the superclass to be able to access objects defined in the first...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
10
by: Bonzol | last post by:
vb.net Hey there, could someone just tell me what the differnce is between classes and modules and when each one would be used compared to the other? Any help would be great Thanx in...
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
32
by: Matias Jansson | last post by:
I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. As I have understood it, it is more common practice to have many...
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
13
by: André | last post by:
Hi, i'm developping asp.net applications and therefore i use VB.net. I have some questions about best practises. According what i read about class and module and if i understand it right, a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.