Solved

Global Variables for ActiveX Documents

Posted on 1999-01-06
2
276 Views
Last Modified: 2011-09-20
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.
0
Comment
Question by:totoro030898
2 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 1454458
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
0
 

Accepted Solution

by:
Ajoy earned 100 total points
ID: 1454459
totoro,
I am submitting this as an answer though i think part of the answer has already been given by 'ameba'.

You can have a Dll with a single class module with as many number of properties as your global variables. In ur 'ActiveX Document A' create an object of this class and whenever u change the values of the global variables, assign it to the object properties accordingly.
On the Click of the 'Next' button in 'document A' pass this object as a reference to 'Document b'. Then assign to the global variables in 'Document b' the property values of this object.
This will make  the global variables in 'document b' to have the new values.
This should solve ur problem.
u can contact me at
Ajoy.tarafder@in.bosch.com
regards,
Ajoy
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

838 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