title: How to declare multiple variables with specifying type using As in VBA?
body: <p>According to <a href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/dim-statement#declaring-multiple-variables" rel="noreferrer">this documentation by Microsoft</a>, the following code can be used to make sure;</p>
  
  <blockquote>
    <p>a, b, and c are all Single; x and y are both Double  </p>
  </blockquote>
  
  <pre class="lang-vb prettyprint-override"><code>Dim a, b, c As Single, x, y As Double, i As Integer  
  &gt; a, b, and c are all Single; x and y are both Double  
  </code></pre>
  
  <p>The logic behind this is as follows</p>
  
  <blockquote>
    <p>You can specify different data types for different variables by using a separate <code>As</code> clause for each variable you declare. Each variable takes the data type specified in the first <code>As</code> clause encountered after its variable name part.</p>
  </blockquote>
  
  <p>However, when I checked with the debugger or <code>MsgBox VarType(a)</code>  output, this is not the case.</p>
  
  <p><a href="https://i.stack.imgur.com/EBD2j.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EBD2j.png" alt="enter image description here"></a></p>
  
  <p>As you can see, it appears that <code>As</code> is only working for the variables right before itself, ie., <code>c</code>, <code>y</code> and <code>i</code>. All others are Variant/Empty and <code>VarType</code> returns 0.</p>
  
  <p>Is this just the documentation being wrong, or am I missing something obvious?</p>
  
  <p>Microsoft Visual Basic for Application 7.1.1056
  Excel 2016 (Windows 10)</p>