Help and Support

How To Implement Array Arguments in Visual Basic COM Objects for Active Server Pages

Article ID:217114
Last Review:July 7, 2008
Revision:5.0
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:
http://www.microsoft.com/technet/security/prodtech/IIS.mspx (http://www.microsoft.com/technet/security/prodtech/IIS.mspx)
For more information about IIS 7.0, visit the following Microsoft Web site:
http://www.iis.net/default.aspx?tabid=1 (http://www.iis.net/default.aspx?tabid=1)
On This Page

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 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-

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:
1.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.
2.In the New Project dialog box, click ActiveX DLL, name it "ASPArray" (without quotation marks), and then click Open.
3.From the Project menu, click Project Properties, click to select the Unattended Execution and the Retained in Memory check boxes, and then click OK.
4.Change the name of the class module to "clsArray" (without quotation marks).
5.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
					
6.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

REFERENCES


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 Internet Information Server 4.0

Back to the top

Keywords: 
kbcodesnippet kberrmsg kbhowtomaster KB217114

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.