How To Implement Array Arguments in Visual Basic COM Objects for Active Server Pages (217114)
The information in this article applies to:
- Microsoft Active Server Pages, when used with:
- Microsoft Internet Information Services 5.0
- 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
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Services 5.0
This article was previously published under Q217114 We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site: SUMMARY
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.
back to the top
Array Argument DeclarationsIMPORTANT: 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-
Type Mismatch
-or-
Object Does not Support This property or method
back to the top
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 )
%>
back to the top
Modification Type: | Minor | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbCodeSnippet kberrmsg kbhowto kbHOWTOmaster KB217114 kbAudDeveloper |
---|
|