all groups > dotnet windows forms > october 2006 >
You're in the

dotnet windows forms

group:

global variables



global variables John A Grandy
10/27/2006 12:48:29 PM
dotnet windows forms: In a WinForms app, how to implement the analog of global variables in a VB6
app ?

Re: global variables Peter Thornqvist
10/27/2006 10:14:36 PM
[quoted text, click to view]

You should really, really avoid global variables, they are bad(TM).

If you have no other option, create a class with static properties/fields
for each variable you need. For good measure, declare a private constructor
so the class cannot be instantiated.

--
Regards, Peter


"John A Grandy" <johnagrandy-at-yahoo-dot-com> skrev i meddelandet
news:OlWJhDg%23GHA.1128@TK2MSFTNGP05.phx.gbl...
[quoted text, click to view]

Re: global variables Emby
10/28/2006 10:40:12 AM
Everything John said is sensible - although IMHO there are definitely times
when global variables make sense.

But, as evil as it may be, one can still implement a VB Module, which is
roughly the equivalent of a VB6 "General" or BAS module.

It appears that the way .NET treats these is essentially what John
recommends to do - it creates a static (or Shared in VB) entity - which
looks an awful lot like a class - where all routines are automatically also
shared.

Anyone know exactly what a VB Module is ?

Anyway, that is one way to implement global members.

Cheers,

[quoted text, click to view]

Re: global variables Emby
10/28/2006 10:42:49 AM
Sorry - got the names swapped - John asked the original question - it was
Peter that offered a response! Duh!

So, Everything PETER said is sensible ... etc ...


[quoted text, click to view]

Re: global variables Peter Thornqvist
10/28/2006 7:52:01 PM
[quoted text, click to view]

Since I don't know very little about VB your suggestion might be a lot
better than mine.

--
Regards, Peter

AddThis Social Bookmark Button