|
-
Mar 26th, 2003, 05:28 PM
#1
Thread Starter
Need-a-life Member
Locked array
I'm getting the error "This array is fixed or temporarily locked" when trying to perform this action:
VB Code:
ReDim Preserve Events(UBound(Events) + 1)
The array is declare as dynamic... so, what's going on?
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Mar 26th, 2003, 05:37 PM
#2
You pass the array to a function (or sub) and THEN you are trying to redim it...
I had the same problem before (long time ago), and I think it's because VB thinks that the first function is still writing data into the array, and when it's writing into the array, it's locking it, and it will unlock it when it's done... probably you pass the variable to a function while it is locked...
Post the code yuou are using, to have a better idea of what it's going on...
-
Mar 26th, 2003, 05:48 PM
#3
Frenzied Member
I don't think that's it. The UBound function returns it's value first, then that value gets incremented by 1, and then the ReDim function resizes the array. I have used this many times without problems.
I do agree that posting more code would be helpfull, so we could get an idea of the context, because your snippet is fine on it's own. Do you happen to know the value of UBound(Events) when the break occurrs?
-
Mar 26th, 2003, 05:54 PM
#4
Isn't "Events" a keyword reserved by Visual Basic ???
I typed Events in vb and presst F1 to check, and it was saying "Keyword Not Found", but still, I would not declare a variable with that name, I would declare it like, myEvents, or... arrayEvents.... etc...
-
Mar 26th, 2003, 05:56 PM
#5
Frenzied Member
I think you're thinking about the WithEvents keyword?
The following works fine for me, although response time slowed dramatically when the array reached 128,000,000 members:
VB Code:
Private Events() As Integer
Private Sub Command1_Click()
ReDim Preserve Events(UBound(Events) * 2)
End Sub
Private Sub Form_Load()
ReDim Preserve Events(1000000)
End Sub
Last edited by seaweed; Mar 26th, 2003 at 06:04 PM.
~seaweed
-
Mar 26th, 2003, 06:54 PM
#6
Thread Starter
Need-a-life Member
Two things.. the one you mentioned, and don't try to redim it if you're inside an With-End With block. Thanks!
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|