Link to home
Start Free TrialLog in
Avatar of totoro030898
totoro030898

asked on

Global Variables for ActiveX Documents

Hi, I am creating some ActiveX Documents for IE3.02 and 4.x, and I created them all in a single project file (ActiveX EXE). I have also some variables declared Global with a default value in a module file.

What I wanted is: when I change the values of these global variables in, say document A, I need these new values to be accessible by other documents. What I did was, when I click a "Next" button on Document A, which has a Hyperlink.NavigateTo "a html with Document B embedded", the global value remains the default on Document B even though Document A has changed it one step before.

Pls help! Thanks.
Avatar of ameba
ameba
Flag of Croatia image

1. If you start your ActiveX EXE 3 times, each instance has its own independent global variables. One way to share variable values is via registry or your own ini or log file.

2. It is easier if you have *only one* instance of ActiveX EXE running and creating all objects. Then each object can access all global variables directly.

3. You can add ActiveX DLL to your ActiveX EXE project references.
Start new ActiveX DLL. Class1 is created by default. Paste this to your Class1:
Option Explicit

Public Property Get GlobalVar() As String
    GlobalVar = gGlobalVar
End Property

Public Property Let GlobalVar(ByVal sNewValue As String)
    gGlobalVar = sNewValue
End Property

Add module to your project. Paste this 2 lines to module1:
Option Explicit
Public gGlobalVar As String

Create dll (project1.dll)

In your ActiveX EXE (or Standard EXE) add reference to project1.dll
To access Global variable, use:
   Dim x As New Project1.Class1
   MsgBox x.GlobalVar ' get variable
   x.GlobalVar = "Document X" ' set variable

Each of your 3 EXEs will create its own x object. But, only 1 DLL will be loaded. Its usage count will be 3.
--
Maybe solution 1. is the simplest
ASKER CERTIFIED SOLUTION
Avatar of Ajoy
Ajoy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial