5

Ist it possible to cal a COM method with the signature

 HRESULT Foo(BSTR in, [out] BSTR * out1, [out] BSTR * out2)

from VBScript?

The following:

 Dim a;
 Dim b;
 component.Foo "something", a, b

gives an error about incompatible types.


I still could change the signature of the method.

peterchen
  • 40,917
  • 20
  • 104
  • 186

1 Answers1

4

Looks like output parameters are not supported; while ByRef / [in, out] parameters are, but only on VARIANT parameters.

From the following KB article:

INFO: Type mismatch errors when you pass parameters from an ASP component to Visual Basic Component @ support.microsoft.com

"VBScript only supports VARIANT ByRef parameters. You can use VBScript to call a procedure that takes ByRef strings, but the default behavior of components built with Visual Basic is to fail with a type mismatch error when trying to pass ByRef parameters to these components. OLE Automation's default type-coercion function fails when asked to convert a ByRef variant into any other ByRef type."

Also, here are other links on the topic:

In, Out, In-Out, Make up your mind Already @ MSDN blogs
VBScript “Type Mismatch” issue with “[in, out] BSTR * ” parameter SO Question

Community
  • 1
  • 1
meklarian
  • 6,595
  • 1
  • 23
  • 49
  • Thanks, I've added a separate method with a "VBS-enabled" signature (`[ref] VARIANT *`) – peterchen Apr 13 '11 at 11:40
  • 1
    @peterchen Could you, please, post the signature of the `COM` method and declaration of the `VARIANT` and the method call in `VBScript`. I can't seem to find a good example for the same problem. – GreatDane Dec 08 '14 at 21:57