title: Initializing a static variable in VBA with non-default value
body: <p>Static variables in VBA are simple enough:</p>
  
  <pre><code>Public Sub foo()
      Static i As Integer
      i = i + 1
      Debug.Print i
  End Sub
  </code></pre>
  
  <p>outputs (when called multiple times):</p>
  
  <pre><code>1
  2
  3
  ...
  </code></pre>
  
  <p>The problem is, VBA does not support initializing a variable on the same line as the declaration (not counting using <code>:</code> to put two lines on one):</p>
  
  <pre><code>Public Sub foo()
      Dim i As Integer = 5 'won't compile!
  
      Dim j As Integer
      j = 5 'we have to do this instead
  End Sub
  </code></pre>
  
  <p>This clashes with static variables:</p>
  
  <pre><code>Public Sub foo()
      Static i As Integer 'we can't put an initial value here...
      i = 5 'so this is how we'd usually initialize it, but...
      i = i + 1
      Debug.Print i
  End Sub
  </code></pre>
  
  <p>You can probably see what happens - The very first thing the variable does every time <code>foo</code> is called is set itself back to 5. Output:</p>
  
  <pre><code>6
  6
  6
  ...
  </code></pre>
  
  <p>How can you initialize a static variable in VBA to a value other than its default? Or is this just VBA dropping the ball?</p>