title: Javascript to ActiveX variable type
body: <p>ActiveX object method has this signature.</p>
  <pre><code>long DirectIO(long Command, long* pData, BSTR* pString)
  
  Int32 DirectIO(Int32, Int32 ByRef, System.String ByRef)
  </code></pre>
  <p>I'm attempting to call this method from javascript.  I've tried many combinations but always get a &quot;Type mismatch&quot; error.</p>
  <p>Reference links:</p>
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/5122704/working-with-out-parameters-in-javascript">Working with &quot;Out&quot; Parameters in JavaScript</a></p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/5646760/calling-com-method-with-foo-out-bstr-value-from-vbscript">calling COM method with Foo(..., [out] BSTR * value) from VBScript</a></p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/1241076/vbscript-type-mismatch-issue-with-in-out-bstr-parameter">VBScript &quot;Type Mismatch&quot; issue with &quot;[in, out] BSTR * &quot; parameter</a></p>
  </li>
  <li><p><a href="https://web.archive.org/web/20120525085934/https://developer.mozilla.org/en/Working_with_out_parameters" rel="nofollow noreferrer">https://web.archive.org/web/20120525085934/https://developer.mozilla.org/en/Working_with_out_parameters</a></p>
  </li>
  <li><p><a href="https://ericlippert.com/2003/09/29/in-out-in-out-make-up-your-mind-already/" rel="nofollow noreferrer">https://ericlippert.com/2003/09/29/in-out-in-out-make-up-your-mind-already/</a></p>
  </li>
  </ul>
  <blockquote>
  <p>So why does VBScript produce a type mismatch error here?  VBScript
  doesn't!  The object produces the type mismatch error, which VBScript
  dutifully reports. The object's implementation of Invoke calls the
  default implementation of Invoke provided for you by the type library
  implementation.  That thing says <em>&quot;I've got a reference to a variant,
  and that variant is a string.  I need a reference to a string.  That's
  a type mismatch.&quot;</em></p>
  </blockquote>
  <ul>
  <li><a href="http://automation-beyond.com/2009/09/01/gp-automation-utilizing-com/" rel="nofollow noreferrer">http://automation-beyond.com/2009/09/01/gp-automation-utilizing-com/</a></li>
  <li><a href="https://web.archive.org/web/20150114065918/http://support.microsoft.com:80/kb/244012" rel="nofollow noreferrer">https://web.archive.org/web/20150114065918/http://support.microsoft.com:80/kb/244012</a></li>
  </ul>