|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Module and ClassHi! I can't understand what difference between modules and classes in VB.NET
project? 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 >Hi! I can't understand what difference between modules and classes in VB.NET A module is basically a class where all the members are implicitly>project? 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. See:
Visual Basic Language Concepts Classes vs. Modules http://msdn2.microsoft.com/en-us/library/7825002w(en-US,VS.80).aspx -- Show quoteHide quoteBest 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" <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? > > "Laserson" <laser***@inbox.ru> schrieb: Classes are used to model /entities/ such as cars, customers, and pets which > I can't understand what difference between modules and classes in VB.NET > project? 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/> 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. -- Show quoteHide quoteDavid 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? > > > "David Anton" <DavidAn***@discussions.microsoft.com> wrote in message I understood everything except that last comment. What do you mean by that?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. 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. 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. -- Show quoteHide quoteDavid 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. > > > 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. : > : > : > David,
>A module is really just a shorthand for a Friend, It can be Public too.>an implicit private constructor to avoid Or rather no constructor at all. A private ctor doesn't prevent>instantiation. 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. 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...?) -- Show quoteHide quoteDavid 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. > >No - if you specify "Public" it still can't be accessed outside of the I can use a public module from another assembly in both v7.1 and v8.0.>project - so for modules "Public" means the same as "Friend". > >(Unless Microsoft has changed this for 2005...?) Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. You're right - I don't know what I was thinking!
-- Show quoteHide quoteDavid 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. > 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? -- Show quoteHide quoteDennis 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. > > 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. -- Show quoteHide quoteDavid 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. > > > Dennis,
> Interesting discussion...I learn something everyday. While reading this For me is it the one as David wrote.> 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? > -- >The one wrinkle is that VB lets you access the members without If you use modules, than in a large project you don't know where the >qualification 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
Option Strict
Declaring Variables Within a If Steatement MDI's Extending Business Object Probably an intro question -> starting window over? calling form_load? Copying DataRows to another DataTable Open pdf file with button in VB 2005 Window Form's icon problem? problem in declaring streamwriter object Error Trapping for trying to run an exe file without supporting files |
|||||||||||||||||||||||