Solved

Public vs Global

Posted on 2003-10-23
4
304 Views
Last Modified: 2010-08-05
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
Comment
Question by:colindow
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:JohnChapin
Comment Utility
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
 

Author Comment

by:colindow
Comment Utility
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
 
LVL 4

Accepted Solution

by:
JohnChapin earned 50 total points
Comment Utility
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
 

Author Comment

by:colindow
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now