INFO: Type Mismatch Errors When You Pass Parameters from ASP to a Visual Basic Component
This article was previously published under Q244012 SUMMARY
The code sample below illustrates various scenarios that causes Type Mismatch errors with method calls from an Active Server Page (ASP) using Visual Basic Script to Visual Basic COM components.
The following is another example that can cause the error:
MORE INFORMATION
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.
VBScript does not impose this restriction. However, it is the default behavior of the component that decides that a ByRef variant cannot be converted into a ByRef string. If a parameter to a procedure is enclosed in parenthesis, the parameter is first evaluated as an expression. Because the result of an expression cannot be passed by reference, the parameter is passed ByVal and no error is reported. Avoid using ByRef parameters unless they are explicitly needed. This is because:
REFERENCESFor additional information, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
197957 (http://support.microsoft.com/kb/197957/EN-US/) PRB: Passing Parameters by Reference to a VC COM Object
197956 (http://support.microsoft.com/kb/197956/EN-US/) PRB: Passing Parameters by Reference to a VB COM Object
174576 (http://support.microsoft.com/kb/174576/EN-US/) HOWTO: Returning Arrays from Server-Side Objects in ASP
218454 (http://support.microsoft.com/kb/218454/EN-US/) HOWTO: Implement Array Arguments in VC COM Objects for Active Server Pages
217114 (http://support.microsoft.com/kb/217114/EN-US/) HOWTO: Implement Array Arguments in Visual Basic COM Objects for Active Server Pages
APPLIES TO
| Article Translations
|

Back to the top
