Greetings.
What's the difference between these 2 (Global and Public) when it comes to declaring variables?
Thanks.
Printable View
Greetings.
What's the difference between these 2 (Global and Public) when it comes to declaring variables?
Thanks.
No difference (other than "Public" is the preferred term). "Public" was introduced in VB5, I believe, and "Global" will eventually be phased out...
No actual difference, but
You can only declare a global variable in a standard module, while public can be declared in both standard modules and classes
They both do the same thing basically....
Am not totally sure if public just allows you to use the variable in one form or in the entire project..but i know global does...
Use PUBLIC and don't bother learning GLOBAL because it is getting obsoleted in Visual Basic 7. Like everyone here said, it is the same concepts.
Ah, yes, but 'Global' makes your application sound so much more powerful
The Global keyword is only kept for backwards compatibility.
I forgot what I was going to write.
.
.
.
Oh yeah, oh wait lost it, I need globals in my head!
Well, you don't need a module for a global but in seperate forms you don't have to put module1.myglobal like you have to use form1.mypublic.
Shouldn't this topic be in chit-chat or the like?
This is VB related. Why would it have to be in the Chit Chat? The thread is seeking information on Public and Global keyword.
This isn't a problem is it? It seems more like it's asking peoples opinions.
It is a problem when the person doesn't know the difference between the two. Don't know which one to use.Quote:
Originally posted by OneSource
Greetings.
What's the difference between these 2 (Global and Public) when it comes to declaring variables?
Thanks.
Exactly, he said, "what's the difference". He didn't say, "I don't know which to use".
You can quote him but not read what he said. Sad.
Hey Bud!
Lets not head into that route with the sad comment!
This is a VB related question and he is asking about something he is not sure about which means he doesn't know.
It is not a topic about Evolution or anything else.
He has more posts than you. :D
We are going to play the post count game now,then Yes he does and comparing to this account only. My other account has 5 times more posts than him.
If you want to continue take it to chit-chat, I don't want to be a hypocrite.
That is the point I was about to make and besides what we are talking about posts count has nothing to do with this thread.
See you around man.
Tyler, is correct. This is a VB topic, however, DigialError, it seems that you guys are turning it into a Chat topic. ;-}
To prevent this thread from getting out of hand, I suggest that future viewers refer to the following thread for more information.
http://forums.vb-world.net/showthrea...threadid=19372
As some one stated Global can not be declared on a form yet Public can. Therefore there is at least one difference.
How about this, (haven't tried it..friday afternoon the first beer is cooling down), if you declare a Public variable in a sub form, (i.e a form called from another form), and declare a Public variable in the sub-form will that variable be available to the calling form. Megatron sounds like he would know the answer to this one:)
Global and Public sound like the old dbase variable types. I vaguely remember that in dbase if you declared a Public variable in a called routine it wasn't available to the calling routine, but was available to routines below the called routine. Whereas a Global variable become available to all routines.
Maybe Microsoft were intending to do something similar, and then thought "What a completely stupid idea", having debugged a number of dBase systems l can concur on that.
but that's not the difference, that's what makes Global useless.
Here's a qwestion for Sam, do you put property Get/Let's instead of Public variables on the form? It's a class too.
Cool Jethro, you put 2 public variables on a sub form, and they will be both available to the calling formQuote:
if you declare a Public variable in a sub form, and declare a Public variable in the sub-form will that variable be available to the calling form
although we degenerated into a little chit-chat for a while.