Microsoft KB Archive/176049

= FIX: Run-time Error "This Array is Fixed or Temporarily Locked" =

Article ID: 176049

Article Last Modified on 8/11/2005

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Enterprise Edition

-



This article was previously published under Q176049





SYMPTOMS
With an .exe file 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 or Service Pack 3 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. This bug has been fixed in Visual Basic 6.0.



Steps to Reproduce Behavior
 Start a new Standard EXE project.</li> Click Components on the Project menu, and then check "Microsoft Databound Grid Control."</li> Draw a dbGrid control and CommandButton on Form1.</li>  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

</li> Click Add Class Module on the Project menu.</li>  Add the following code to Class1: Public Sub MyMethod(x As Variant)

End Sub

</li> 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.</li></ol>

Additional query words: kbVBp500bug kbSPack kbDSupport kbdsd kbVBp kbVBp600fix kbSSafep2

Keywords: kbbug kbfix kbgrpdsvb KB176049

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.