|
-
Sep 15th, 2005, 01:45 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Problem with Redim Preserve
I'm getting a "Subscript out of range (Error 9)" on the 3rd line in the attached code.
The ReDim Preserve is in a loop where I need to add incremental rows to the array, the width will always stay constant at 10.
Any ideas what I'm doing wrong? (I know I've gotten this to work before, but can't see what I've done differently here)
Note: Option Base = 1
VB Code:
Dim MyArray() As Integer
'Later
ReDim MyArray(1, 10)
'Later still
ReDim Preserve MyArray(UBound(MyArray, 1) + 1, 10)
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Sep 15th, 2005, 02:28 PM
#2
Re: Problem with Redim Preserve
Using an multi-dimensional array, you're only allowed to change the last dimension!
Allowed:
VB Code:
Dim MyArray() As Integer
.
.
ReDim MyArray(1, 10)
.
.
ReDim Preserve MyArray(1,UBound(MyArray, 1) + 1)
NOT Allowed:
VB Code:
Dim MyArray() As Integer
.
.
ReDim MyArray(1, 10)
.
.
ReDim Preserve MyArray(UBound(MyArray, 1) + 1,10)
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Sep 15th, 2005, 07:43 PM
#3
Thread Starter
Frenzied Member
Re: Problem with Redim Preserve
Thanks, I knew it was something stupid I was doing.
VB Code:
With DKenny
If .HoursAsleep < 3 Then
.Brain = False
End If
End With
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
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
|