DOCUMENT:Q176049 03-NOV-1997 [vbwin] TITLE :BUG: Run-time Error "This Array is Fixed or Temporarily Locked" PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:5.0 OPER/SYS:WINDOWS KEYWORDS:vb5all VBKBEnv kberrmsg VS97FixlistSP2 ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0 --------------------------------------------------------------------- SYMPTOMS ======== With an EXE made from a Visual Basic project, you receive the following error: Run-time error 10: "This Array is fixed or temporarily locked" The error does not occur when the Visual Basic project is run in the design environment. CAUSE ===== This error occurs when your project uses the Microsoft Data-bound Grid control and you pass an element of a variant array to a procedure in a class module. This problem only occurs in Visual Basic 5.0 if the Visual Basic 5.0 Service Pack 2 is installed. RESOLUTION ========== There are several possible workarounds for this problem: - Dimension the array as a type other than Variant. For example, dimension the array as type String. -or- - Pass the element of the array by value. -or - - Use a temporary variable to store and retrieve the value of the array element. For example, this code uses a variable "temp" to store and retrieve the value of the first element of "myarray": temp = myarray(1) MyObject.MyMethod temp myarray(1) = temp 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 Standard EXE project. 2. Click Components on the Project menu, and then check "Microsoft Databound Grid Control." 3. Draw a dbGrid control and CommandButton on Form1. 4. Add the following code to Form1: Dim o As Object Private Sub Command1_Click() test End Sub Private Sub test() Set o = New Class1 ReDim myarray(1) As Variant o.MyMethod myarray(1) End Sub 5. Click Add Class Module on the Project menu. 6. Add the following code to Class1: Public Sub MyMethod(x As Variant) End Sub 7. Make the EXE and then run the EXE. Click Command1 and note that you receive the run-time error #10 and the application will quit. ====================================================================== Keywords : vb5all VBKBEnv kberrmsg VS97FixlistSP2 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.