Microsoft KB Archive/217114

From BetaArchive Wiki

Article ID: 217114

Article Last Modified on 6/23/2005



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 6.0 Enterprise Edition
  • 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 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

back to the top

Keywords: kberrmsg kbhowto kbhowtomaster kbcodesnippet KB217114