jamesanthony Posted October 29, 2003 Posted October 29, 2003 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 Quote
Moderators Robby Posted October 29, 2003 Moderators Posted October 29, 2003 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 Quote Visit...Bassic Software
Mohsen Posted October 30, 2003 Posted October 30, 2003 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 Quote
Jay1b Posted October 30, 2003 Posted October 30, 2003 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. Quote
jamesanthony Posted October 30, 2003 Author Posted October 30, 2003 Great Answers Cheers all who answered, good honest no nonsence stuff. Thanks again JR Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.