Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Public vs Global

Posted on 2003-10-23
4
319 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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