954,582 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Global v/s Public

Wot is the difference between declaring a Global Variable and a Public variable?

I mean both variables can be accessed through out the project so wots the main difference apart from that Global variables cannot be declared in forms but modules only?

cancer10
Posting Whiz in Training
234 posts since Dec 2004
Reputation Points: 58
Solved Threads: 1
 

'Global' isn't actually a type of variable, the term is used to refer to the scope of a variable. For instance, if you declare the variable in the general section of a form ( even just using DIM ), it is 'global' to that form.
Declare it in a module and it is global to the whole project, but in this case I think you must use PUBLIC. (Any comment from other members about this?)

w00dy
Junior Poster in Training
70 posts since Jun 2005
Reputation Points: 11
Solved Threads: 2
 

That's correct. Global Variables defined in a mod use the global prefix. Global Variables defined on a form use public. That is about the only difference.

jwshepherd
Junior Poster
123 posts since Jun 2005
Reputation Points: 20
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You