INFO: Type Mismatch Errors When You Pass Parameters from ASP to a Visual Basic Component (244012)
The information in this article applies to:
- Microsoft Active Server Pages
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
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.
'VB Code : [Project=prjParam;Class=clsParam]
'By default, the parameter is passed 'ByRef'
Sub x( a as string )
a = "Changed"
End Sub
'ASP Code
k = "Hello"
'Create the above VB object
Set obj = Server.CreateObject("prjParam.clsParam")
obj.x k 'Type Mismatch error occurs
obj.x (k) 'Using PARANTHESIS forces 'ByVal' , 'k' does not change
Call obj.x (k) 'Type Mismatch error occurs
Call obj.x cstr(k) 'The CSTR function returns a string,
'the address of the variable (k) is not passed.
'The value of 'k' doesn't change
Set obj = Nothing
The following is another example that can cause the error:
'VB Code : [Project=prjParam;Class=clsParam]
'If you do not specify, by default the parameter is passed 'ByRef'
'Note: Parameter type is VARIANT
Sub y( a as variant )
a = "Changed"
End Sub
'ASP Code
k = "Hello"
'Create the above VB object
Set obj = Server.CreateObject("prjParam.clsParam")
obj.y k 'changes 'k'
obj.y (k) 'Using PARANTHESIS forces 'ByVal' , 'k' doesn't change
Call obj.y (k) 'changes 'k'
Set obj = Nothing
REFERENCESFor additional information, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
197957 PRB: Passing Parameters by Reference to a VC COM Object
197956 PRB: Passing Parameters by Reference to a VB COM Object
174576 HOWTO: Returning Arrays from Server-Side Objects in ASP
218454 HOWTO: Implement Array Arguments in VC COM Objects for Active Server Pages
217114 HOWTO: Implement Array Arguments in Visual Basic COM Objects for Active Server Pages
Modification Type: | Major | Last Reviewed: | 11/26/2003 |
---|
Keywords: | kbCodeSnippet kberrmsg kbinfo KB244012 |
---|
|