Link to home
Start Free TrialLog in
Avatar of colindow
colindow

asked on

Public vs Global

I have some code which came from an old VB3 project.

The some constants and variables are declared as Global. In some VB6 code I have they are declared as Public.

Is there actually a functional difference between the two methods of declaration.
Avatar of JohnChapin
JohnChapin

Global variables are those variable declared using PUBLIC in bas module, and therefoe canbe seen throughout the project.
They survive for the life of the application and are visible from all of the application.
Microsoft supports the term in VB6 but does not encourage its use.

Public variables declared in FORM or Class modules are only valid while that form or class is instantiated (existing).

Hope this helps, John
Avatar of colindow

ASKER

so replacing Global Const With Public Const in all bas files will not change anything but will mean that the syntax is more consistent?
ASKER CERTIFIED SOLUTION
Avatar of JohnChapin
JohnChapin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No, I assumed that they were the same but just before I went for the Replace button I thought I might just check.....