Print Page | Close Window

Module VS Class

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=6701
Printed Date: 29 March 2026 at 10:52am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Module VS Class
Posted By: Diep-Vriezer
Subject: Module VS Class
Date Posted: 25 October 2003 at 6:31am

Hey guys,

I'm building a web application in ASP.NET (..), and have to request quite a few values from cookies. Now, you can't peform any of the Request commands in classes, can you do that in modules?

If not, why should I use a module instead of a class?  Look's like they're the same so.. Cause now I have to redirect clients to tons of pages, because they need the QueryString, wich is not really secure and stuff.

So, what is the difference between a module and a class.



-------------
Gone..



Replies:
Posted By: The WizeGuy
Date Posted: 25 October 2003 at 4:21pm

You can do that in Classes!

Dim _ctx As HttpContext = HttpContext.Current
Dim _cookVal As String = _ctx.Request.Cookies("CookieName")("CookieKey")

thats about IT!

cya,

/PatrikB 



Posted By: The WizeGuy
Date Posted: 25 October 2003 at 4:22pm
Originally posted by Diep-Vriezer Diep-Vriezer wrote:

So, what is the difference between a module and a class.

Originally posted by NET Framework SDK NET Framework SDK wrote:

Modules are a reference type similar to classes, but with some important distinctions. The members of a module are implicitly Shared and scoped to the declaration space of the standard module's containing namespace, rather than just to the module itself. Unlike classes, modules can never be instantiated, do not support inheritance, and cannot implement interfaces. A module can only be declared in a namespace and cannot be nested in another type.

You can have multiple modules in a project, but members with the same name defined in two or more modules must be qualified with their module name when accessed outside of their module.

cya,

/PatrikB



Posted By: Diep-Vriezer
Date Posted: 25 October 2003 at 4:22pm

thx, never thought about that. DUMB.



-------------
Gone..


Posted By: Boecky
Date Posted: 26 October 2003 at 3:16pm

So if i understand good...
I ALWAYS have to do this when I use a module:

module1.test()

There is no way to import something (module1) that I just can use test() ?



Posted By: Bunce
Date Posted: 26 October 2003 at 5:57pm

You have the answer in your question!

Use the IMPORTS statement at the top of your page, so rather than

MyClass.Test

in your page, you can do

Imports Myclass
.
.
.
Test()

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: Diep-Vriezer
Date Posted: 27 October 2003 at 12:42am

I use this in such cases:

Dim MyClassRefferer As New MyClass

EDIT: I should have read your question better, this will still have the MyClassRefferer.Test() req. Use Imports MyClass instead, as described above.



-------------
Gone..


Posted By: Boecky
Date Posted: 27 October 2003 at 12:46am
Oh I thought the import statement was only for classes, but it works also with the modules!


Posted By: Diep-Vriezer
Date Posted: 27 October 2003 at 12:49am

It works with everything.. It really is a powerfull framework!



-------------
Gone..


Posted By: Boecky
Date Posted: 31 October 2003 at 1:39pm
Here they explain some differences between classes and modules

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20312592.html - http://www.experts-exchange.com/Programming/Programming_Lang uages/Visual_Basic/Q_20312592.html



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net