title: declaring global array in Visual Basic Editor
body: <p>No other answer seems to work for me so I'm resorting to asking a question that everyone sees to be having trouble with. Simple stuff on any other language but VBA. I just want to initialize a global array of strings, and make use of it in my main sub.</p>
  
  <p>Here's test1 where I just tried to return it from a public function:</p>
  
  <pre><code>Public Function effthis1() As String()
      ReDim effthis1(0 To 10)
      myStr = "a b c d e f g h i j k"
      strsplit = Split(myStr)
  
      j = LBound(effthis)
      For Each word In strsplit
          effthis1(j) = word
          j = j + 1
      Next
  
  End Function
  
  Sub test1()
      testStr = effthis1(4)
      MsgBox testStr
  End Sub
  </code></pre>
  
  <p>Here's test2 where I tried with a sub that gets called within the main sub:</p>
  
  <pre><code>Public effthis2() As String
  
  Sub declareMyArray()
  
  effthis2(0) = "a"
  effthis2(1) = "b"
  effthis2(2) = "c"
  effthis2(3) = "d"
  effthis2(4) = "e"
  effthis2(5) = "f"
  effthis2(6) = "g"
  effthis2(7) = "h"
  effthis2(8) = "i"
  effthis2(9) = "j"
  effthis2(10) = "k"
  
  End Sub
  
  Sub test2()
      declareMyArray
      MsgBox effthis2(4)
  End Sub
  </code></pre>
  
  <p>MSDN is not helping at all. Thanks in advance, George</p>