Solved

Public vs Global

Posted on 2003-10-23
4
309 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
ID: 9606354
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
ID: 9606387
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
ID: 9606402
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
ID: 9606489
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

919 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

12 Experts available now in Live!

Get 1:1 Help Now