开发者

Why Doesn't a Global Var Declared in one VB6 project Compile in Another Project in same VB6 Project Group?

I apologize that this is such an elementary question.

Our VB6 project group contains 6 projects plus the UI project containing all the app's forms.

We generate a uniqueID (gstrUniqueImportUuid) in the code behind one of the forms, which must be exposed to a class in another project in the project group.

I've tried declaring this variable as a global variable in the Common.bas module that's part of the main UI project, like this:

Option Explicit
Public gstrUniqueImportUuid As String

I then assign a value to gstrU开发者_Python百科niqueImportUuid in the form, which works fine.

But then when I try to use that global variable's value in one of the other projects in the group, that project won't compile--"variable not defined".

What on earth am I doing wrong?

Thank you.


Modules are not public outside of the Project. What you want to do is create a class and set it's instancing to GlobalMultiUse. Any public properties of that class will be visible to any project referencing that project. Note you con only do this for ActiveX DLLs and ActiveX EXEs.


I'm guessing a bit now, but does the "other project" where you try to use the variable have a reference to the "UI project"? The Ui project must be checked in the references list in menu project->references.

Usually it's the UI project that is referencing one or more other projects but not the other way around. Even if the variable is global the project where it is declared in must be referenced.

If the reference doesn't exist and you can't add the reference (you might be getting circular dependencies) you can move the declaration of the field gstrUniqueImportUuid to one of the other projects .bas files. The project you move it to (if not the "other project" must be referenced to by the UI project (and the "other project")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜