Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 217114 - Last Review: July 7, 2008 - Revision: 5.1
How To Implement Array Arguments in Visual Basic COM Objects for Active Server Pages
This article was previously published under Q217114
We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 7.0 running on Microsoft Windows Server 2008. IIS 7.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:
For more information about IIS 7.0, visit the following Microsoft Web site:
This step-by-step article describes how to implement arrays to be passed as parameters from Active Server Pages (ASP) to a Visual Basic Component
Object Model (COM) Object.
Array Argument Declarations
IMPORTANT: If array arguments are for methods, they must be declared as variant data type and must be passed by reference. If you declare an array argument as any other type, you may receive one of the following error messages:
error 'ASP 0115' - A trappable error occurred in an external object
-or-
Invalid procedure call or argument
-or-
-or-
Object Does not Support This property or method
Implement Arrays
Follow these steps to implement arrays to be passed as parameters from ASP to a Visual Basic COM Object:
- From the Microsoft Windows Start menu, point to Programs, point to Microsoft Visual Studio 6.0, and then click Microsoft Visual Basic 6.0 to open Visual Basic.
- In the New Project dialog box, click ActiveX DLL, name it "ASPArray" (without quotation marks), and then click Open.
- From the Project menu, click Project Properties, click to select the Unattended Execution and the Retained in Memory check boxes, and then click OK.
- Change the name of the class module to "clsArray" (without quotation marks).
- Implement the following function:
Public Function TestArray( ByRef vArray as Variant ) as String
Dim nCnt as integer
'Verify that the argument passed is an array
If Not IsArray( vArray ) Then
TestArray = "Parameter is not an Array"
Exit Function
End If
For nCnt = LBound(vArray) to UBound(vArray)
'Traverse Array Element
Next nCnt
TestArray = "Parameter is an Array"
End Function
- Create an ASP page with the following code:
<%
Dim oTestObj, vMyArray(2), vRtnValue
vMyArray(0) = "Element 1"
vMyArray(1) = "Element 2"
vMyArray(2) = "Element 3"
Set oTestObj = Server.CreateObject("ASPArray.clsArray")
vRtnValue = oTestObj.TestArray( vMyArray )
Response.Write( "Return Value = " & vRtnValue )
%>
APPLIES TO
- Microsoft Active Server Pages 4.0, when used with:
- Microsoft Internet Information Services 5.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 kbhowtomaster KB217114 |
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