I have a dynamic array
Now I want to redim this array so I use :Code:dim myarray() as string
Code:redim preserve myarray(intctr)
Works fine.
But for two dimensional arrays - its giving me an error - subscript out of range. what do I do?
Printable View
I have a dynamic array
Now I want to redim this array so I use :Code:dim myarray() as string
Code:redim preserve myarray(intctr)
Works fine.
But for two dimensional arrays - its giving me an error - subscript out of range. what do I do?
It'll need to dimmed to a value first (such as 0)
The first dim statement cannot be a redim preserve, as it hasn't yet been dimmed.
That help?
Thanks Arbiter for replying but,
Nope didnt work.
:(
Post your full code/project and I'll have a look.
Click on the command twice to get the error.Code:Dim myArray() As String
Dim intctr As Integer
Private Sub Command1_Click()
intctr = intctr + 1
ReDim Preserve myArray(intctr, 2)
End Sub
I think , there is soenthing smalll we are missing....
Thanks for ur time
the error was u cannot increment the lower bound in redim i 2D array
Code:Dim myArray() As String
Dim intctr As Integer
Private Sub Command1_Click()
intctr = intctr + 1
ReDim Preserve myArray( 2,intctr)
End Sub
Would work.
thanks anyways
I think the problem is the
dim myarray()
only sets the array up as a 1D dynamic array.
Let me have a play and get back to you...
Arbiter - Thanks a lot for your time.
But see my previous post - I have got the soln - pls do not waste ur time on it.
I'm using the following
VB Code:
Dim myarray() As Integer, x As Integer Private Sub Command1_Click() x = x + 1 ReDim Preserve myarray(1, x) End Sub Private Sub form_load() [b]Dim myarray(0, 0)[/b] End Sub
The bit in bold is the bit that I meant you'd need in order to kick the array off
Works without it as well.:)
Oh, right, yeah.
I'll shut up now... :rolleyes:
I completely misread your last post anyway.
I think I need a beer....
Anyways thanks a lot.:)