• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

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.
0
colindow
Asked:
colindow
  • 2
  • 2
1 Solution
 
JohnChapinCommented:
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
0
 
colindowAuthor Commented:
so replacing Global Const With Public Const in all bas files will not change anything but will mean that the syntax is more consistent?
0
 
JohnChapinCommented:
That's right.
However, according to the book, you should not have to replace them.
There should be no compile error on those statements.
Are you having a problem compiling with something?
John
0
 
colindowAuthor Commented:
No, I assumed that they were the same but just before I went for the Replace button I thought I might just check.....

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now