Interop Forms Toolkit
How To Share Application State in a Hybrid Application

Overview

Application state is often passed from one component to another within an application.  Visual Basic 6.0 applications often use global variables to do this.  .NET does not support global variables; however, since there may on occasion be good reason to pass state as a global variable, the Interop Forms Toolkit supports it.  Global values can be added and removed to the InteropToolbox.Globals collection.

 

Below is an example of setting a value in the Globals collection from Visual Basic 6.0 code:

        ' Add the token to the Interop Globals collection so that
        ' .NET components can use it.
        g_InteropToolbox.Globals.Add AUTHENTICATION_TOKEN, authToken

 

Below is an example of retrieving a value from the Globals collection within a .NET InteropForm. .NET code allows for accessing the InteropToolbox from the My namespace:

        Dim authToken As String = My.InteropToolbox.Globals(AUTHENTICATION_TOKEN)

Note: For proper memory management, items that were added to Globals that are no longer needed should be explicitly removed using the Remove method.