Defining Global Variables

Bill_Gates

$163 Billion Dollar Man
Local time
Today, 05:37
Joined
Oct 22, 2010
Messages
11
I want to define, not just declare, a global string array for use in all my subs and functions in my module.

I know how to define a global function, but I can not call this function in the same way I could call an array.

I could use a class, but I want all the code to be in the same standard module.

All I want to do is something like:

Global StringArray() As String

StringArray(1) = "First String"
StringArray(2) = "Second String"

etc

And be able to access the members of the array elsewhere.

Any ideas?
 
I use a module I call "modGlobals" where I place all my globals I am going to use throughout the app, including arrays. The module contains one sub, called "initGlobals" called when the app opens to initialize values. Looks something like this:

Global StringArray() As String
Global gAnIntVar as Integer
Global gAString as String

Sub initGlobals()
StringArray(1) = "First String"
StringArray(2) = "Second String"
gAnIntVar = 1
gAString = "This is a global string"
End Sub
 
Chipper, that worked well.

Thank you!
 

Users who are viewing this thread

Back
Top Bottom