Type Mismatch Error calling VB COM component from VBScript 
Author Message
 Type Mismatch Error calling VB COM component from VBScript

I am developing a COM component in VB, to be called from ASP VBScript.
The COM component has a method with the following signature:

Sub GetScenarios(ByRef oRs As ADODB.Recordset, CustomerNumber As
Integer)

When I call the method from VBScript:

Set oGuideGlue = Server.CreateObject( "GlueTest.GlueTestDB" )
Set objRS = Server.CreateObject("ADODB.Recordset")
oGuideGlue.GetScenarios objRS, 2

 I get a "type mismatch error". As I understand it, it is perfectly
legal to call a strongly typed method from VBScript. A deja search
revealed that this issue has come up before, and it has been suggested
that objects, which are to be used with VBScript, should have
arguments typed as Variant. This just doesn't seem correct, since it
would require the COM component developer to know in advance which
clients would use the component.

Does anyone know what is happening here? This is very frustrating.



Wed, 16 Jul 2003 01:58:42 GMT  
 Type Mismatch Error calling VB COM component from VBScript
oGuideGlue.GetScenarios (objRS), (2)

will force the arguments to be expressions that can be passed effectively ByVal to even strongly
typed ByRef parameters.

This works as long as the method doesn't really *need* ByRef (i.e., to reassign a new value to the
passed argument).  In this case there's really no need for the method GetScenarios to use ByRef to
start with, either explicitly on the 1st parameter or implicitly on the 2nd.  If they were both
coded explicitly as ByVal then your original VBScript call would have worked fine.

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--


Quote:
> I am developing a COM component in VB, to be called from ASP VBScript.
> The COM component has a method with the following signature:

> Sub GetScenarios(ByRef oRs As ADODB.Recordset, CustomerNumber As
> Integer)

> When I call the method from VBScript:

> Set oGuideGlue = Server.CreateObject( "GlueTest.GlueTestDB" )
> Set objRS = Server.CreateObject("ADODB.Recordset")
> oGuideGlue.GetScenarios objRS, 2

>  I get a "type mismatch error". As I understand it, it is perfectly
> legal to call a strongly typed method from VBScript. A deja search
> revealed that this issue has come up before, and it has been suggested
> that objects, which are to be used with VBScript, should have
> arguments typed as Variant. This just doesn't seem correct, since it
> would require the COM component developer to know in advance which
> clients would use the component.

> Does anyone know what is happening here? This is very frustrating.



Wed, 16 Jul 2003 06:33:27 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Type Mismatch Error calling VB COM component from VBScript

2. Type mismatch error using ADO / ASP / VB COM Component

3. COM error: eVB calling eVC object give type mismatch

4. Type mismatch when calling VB6 COM objects from VB.NET

5. asp - VB component error (type mismatch)

6. Type mismatch when calling component

7. Type mismatch when calling component

8. 'type mismatch' when calling COM DLL

9. Type mismatch when calling COM methods

10. Parameter type-mismatch problem calling Java applet from VBScript

11. Type Mismatch error in COM ADDIN

12. Type Mismatch Errors in VBScript?

 

 
Powered by phpBB® Forum Software