Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All

I have asked this before and got the grunted answer, "Thats the way it is now, get used to it".

Anyway my problem

I Cannot program without global variables

I keep a lot of information global ie.

Printer Names and locations.

User login names

Server Names

Database Names

Etc

Etc

It would mean for every form I have I must supply all this global information again. Is this correct. I thought .NET was an improvment on VB6. so far I cant see it, everything gets so complicated and long winded with tons of code.

Hardly 4th generation stuff.

Any help or suggestions appreciated.

Cheers

JR

  • Moderators
Posted

With the statements you've made I'm not sure on how I should reply.

 

If you insist on using global variables then create a module and stick the public variables in there.

 

If you want to things the long-winded way which by the way is the correct way, then check out some of these articles or books on Object Oriented programming ... http://www.google.com/search?hl=en&ie=ISO-8859-1&q=object+oriented+programming+.net+101

Visit...Bassic Software
Posted

Well I think that Robby was right. Create a module, initialize public variable in it. And on the first from, assign values to this varialbe, and then use them in all your form without assigning new values to them, and without declaring them. They'll take the values of the first form.

Cheers,

Mohsen

Posted

Whats the right way and the wrong way - really does just depend what works.

 

Go with declaring them globally in the module. Using classes does have its advantages - but if you not planning to use those advantages, then theres no point in overly worrying about them.

 

Obviously using the classes is good practice for when you may want to take advantage of there flexibility.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...