title: Type mismatch when passing string variable into Variant parameter, and assigning result of Array function to parameter
body: <p>I have the following two procedures:</p>
  
  <pre><code>Sub OuterSub()
      Dim s As String
      s = "Lorem ipsum dolor sit amet"
      InnerSub s
  End Sub
  
  Sub InnerSub(prm As Variant)
      prm = Array(prm)
  End Sub
  </code></pre>
  
  <p>When I run <code>OuterSub</code>, I get the following error at <code>prm = Array(prm)</code> in <code>InnerSub</code>:</p>
  
  <blockquote>
    <p>Run-time error '13': Type mismatch</p>
  </blockquote>
  
  <p>This only happens when I pass in a variable typed as <code>String</code>. Any of the following alternatives doesn't produce the error:</p>
  
  <ul>
  <li>Defining <code>s</code> in <code>OuterSub</code> as a constant:<br>
  <code>Const s = "Lorem ipsum dolor sit amet"</code>  </li>
  <li>Passing in a string literal:<br>
  <code>InnerSub "Lorem ipsum dolor sit amet"</code>  </li>
  <li>Defining <code>s</code> in <code>OuterSub</code> as a <code>Variant</code>:<br>
  <code>Dim s As Variant</code>  </li>
  </ul>
  
  <p>Defining <code>s</code> as a fixed-length string doesn't help.</p>
  
  <p><strong>Why is this happening? How can I work around it?</strong></p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Declaring a local <code>String</code> variable within <code>InnerSub</code> also doesn't help:</p>
  
  <pre><code>Sub InnerSub(prm As Variant)
      Dim s As String
      s = prm
      prm = Array(s)
  End Sub
  </code></pre>
  
  <p>nor does wrapping the parameter in parentheses:</p>
  
  <pre><code>Sub InnerSub(prm As Variant)
      prm = Array((prm))
  End Sub
  </code></pre>