
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.