Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 197956 - Last Review: March 14, 2005 - Revision: 4.2
PRB: Passing Parameters By Reference to a VB COM Object
This article was previously published under Q197956
When passing a parameter to a COM Component's method in Active Server Pages
(ASP), the following error occurs:
Microsoft VBScript runtime error '800a000d' Type mismatch
Or the value stored in the variable passed to the method is not changed.
VBScript will pass parameters to a method by value if the argument's data
type is NOT declared as a variant and the parameter is passed by reference
if the argument's data type is declared as variant by the method.
Parameters to be passed by reference to a method should always be declared
as a variant data type by the method, while parameters to be passed by
value can be declared as any type by the method.
This behavior is by design.
Steps to Reproduce Behavior
- Create a Visual Basic ActiveX DLL Project called "ByRefProj."
- Add class module called "ByRefObj."
- Implement the following method:
Public Sub ByRefMethod( ByRef strVal as String )
strVal = "This variable is passed by Reference"
End Sub
- Create an ASP Page that calls this Method:
<%
Dim objTest, strByRefVal
Set objTest = Server.CreateObject("ByRefProj.ByRefObj")
objTest.ByRefMethod strByRefVal
%> - Run ASP. The following error occurs:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'ByRefMethod'
To correct this behavior:
Change the implementation of the method ByRefMethod as follows:
Public Sub ByRefMethod( ByRef strVal as Variant )
strVal = "This variable is passed by Reference"
End Sub
APPLIES TO
- Microsoft Active Server Pages 4.0
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 6.0 Learning Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Services 5.0
| kbcodesnippet kberrmsg kbprb KB197956 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate