Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Module VS Class
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Module VS Class

 Post Reply Post Reply Page  12>
Author
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Topic: Module VS Class
    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..
Back to Top
The WizeGuy View Drop Down
Newbie
Newbie


Joined: 02 October 2003
Location: Sweden
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote The WizeGuy Quote  Post ReplyReply Direct Link To This Post 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 

Back to Top
The WizeGuy View Drop Down
Newbie
Newbie


Joined: 02 October 2003
Location: Sweden
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote The WizeGuy Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 25 October 2003 at 4:22pm

thx, never thought about that. DUMB.

Gone..
Back to Top
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post 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() ?

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post 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.



Edited by Diep-Vriezer
Gone..
Back to Top
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post Posted: 27 October 2003 at 12:46am
Oh I thought the import statement was only for classes, but it works also with the modules!
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.