Why is a global var declared in one VB6 project compiled into another project in the same VB6 Project Group?

I apologize that this is such an elementary question.

Our VB6 project group contains 6 projects plus a user interface project containing all application forms.

We generate a unique identifier (gstrUniqueImportUuid) in the code for one of the forms, which must be presented to the class in another project in the project group.

I tried to declare this variable a global variable in the Common.bas module as part of the main user interface project, for example:

Option Explicit Public gstrUniqueImportUuid As String 

Then I assign the value gstrUniqueImportUuid in a form that works fine.

But then, when I try to use this value of a global variable in one of the other projects in the group, this project will not compile - "the variable is not defined."

What am I doing wrong?

Thanks.

+4
source share
2 answers

Modules are not public outside the project. What you want to do is create a class and set it up to GlobalMultiUse. Any public properties of this class will be visible to any project that references this project. Please note that you only do this for ActiveX dlls and ActiveX dlls.

+4
source

Now I’m a little guessing, but does it have a “different project”, where are you trying to use a variable, a link to a “user interface project”? The Ui project should be checked in the list of links in the project-> reference menu.

This is usually a user interface project that references one or more other projects, but not vice versa. Even if the variable is global, the project in which it is declared must be specified.

If the link does not exist, and you cannot add the link (you can get circular dependencies), you can move the declaration of the gstrUniqueImportUuid field to one of the other .bas project files. The project you are moving it to (if not a "different project" that the user interface project should reference (and "another project")

+1
source

Source: https://habr.com/ru/post/1345482/


All Articles