DOCUMENT:Q177090 24-NOV-1997 [vbwin] TITLE :BUG: Returning Empty Array from ActiveX EXE Fails with SP2 PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:5.0 OPER/SYS:WINDOWS KEYWORDS:VBKBAX VBKBObj kberrmsg ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0 --------------------------------------------------------------------- SYMPTOMS ======== You receive an error when you use the Array function to return an empty variant array from an out-of-process ActiveX Component (ActiveX EXE): Run-time error '5': Invalid Procedure Call or Argument This error occurs only after the installation of Visual Studio 97 Service Pack 2. RESOLUTION ========== There are several workarounds to this problem: - Use an in-process ActiveX Component (ActiveX DLL). -or- - Implement error handling in the client application. -or- - Instead of returning an empty array, return Array(vbNull). Note that this will actually return an array that has one element. STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- 1. Start a new ActiveX EXE project in Visual Basic 5.0 (with Visual Studio 97 SP2 installed). 2. Click Project1 Properties on the Project menu, and change the name of the Project to "TestArrayPass." 3. Add the following code to Class1: Public Function testPass() testPass = Array() End Function 4. Run the project. 5. Start another instance of Visual Basic and select a new Standard EXE project. Form1 is created by default. 6. Click References on the Project menu, and check "TestArrayPass." 7. Place the following code in Form1: Private Sub Form_Load() Dim myObj As testArrayPass.Class1 Dim result Set myObj = New testArrayPass.Class1 result = myObj.testPass End Sub 8. Run the project and note that you receive the run-time error previously described. ====================================================================== Keywords : VBKBAX VBKBObj kberrmsg Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbbug ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1997.