下面的代码示例说明了各种方案,从而导致
与方法调用从 Visual Basic 脚本使用 Visual Basic COM 组件的活动服务器页面 (ASP) 错误。
在以下条件,可能会导致错误的另一个示例:
类型不匹配
'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
'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
更多信息
有关更多的信息请单击下面文章编号,以查看 Microsoft 知识库中相应的文章:
197957
(http://support.microsoft.com/kb/197957/EN-US/ ) 通过到 VC COM 对象的引用 PRB: 传递参数
197956
(http://support.microsoft.com/kb/197956/EN-US/ ) 通过到 VB COM 对象的引用 PRB: 传递参数
174576
(http://support.microsoft.com/kb/174576/EN-US/ ) HOWTO: 返回在 ASP 的服务器端对象中的数组
这篇文章中的信息适用于:
- Microsoft Active Server Pages 4.0
- Microsoft Visual Basic 5.0 学习版
- Microsoft Visual Basic 6.0 学习版
- Microsoft Visual Basic 5.0 专业版
- Microsoft Visual Basic 6.0 专业版
- Microsoft Visual Basic 5.0 企业版
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
关键字: |
kbmt kbcodesnippet kberrmsg kbinfo KB244012 KbMtzh |