Solved

Global Variables for ActiveX Documents

Posted on 1999-01-06
2
281 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
[X]
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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hide vba in gp 7 114
VB6 ListBox Question 4 55
MS SQL Update query with connected table data 3 59
Help with Classic ASP - Parameterizing Query 16 16
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

763 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