|
-
Jan 9th, 2002, 06:18 AM
#1
Thread Starter
PowerPoster
[Resolved - silly me]2D arrays - silly q
I have a dynamic array
Code:
dim myarray() as string
Now I want to redim this array so I use :
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?
Last edited by veryjonny; Jan 9th, 2002 at 07:02 AM.
-
Jan 9th, 2002, 06:24 AM
#2
PowerPoster
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?
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Jan 9th, 2002, 06:34 AM
#3
Thread Starter
PowerPoster
Thanks Arbiter for replying but,
Nope didnt work.
-
Jan 9th, 2002, 06:45 AM
#4
PowerPoster
Post your full code/project and I'll have a look.
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Jan 9th, 2002, 06:51 AM
#5
Thread Starter
PowerPoster
hi
Code:
Dim myArray() As String
Dim intctr As Integer
Private Sub Command1_Click()
intctr = intctr + 1
ReDim Preserve myArray(intctr, 2)
End Sub
Click on the command twice to get the error.
I think , there is soenthing smalll we are missing....
Thanks for ur time
-
Jan 9th, 2002, 07:01 AM
#6
Thread Starter
PowerPoster
solved it
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
-
Jan 9th, 2002, 07:04 AM
#7
PowerPoster
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...
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Jan 9th, 2002, 07:08 AM
#8
Thread Starter
PowerPoster
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.
-
Jan 9th, 2002, 07:09 AM
#9
PowerPoster
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
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Jan 9th, 2002, 07:10 AM
#10
Thread Starter
PowerPoster
Works without it as well.
-
Jan 9th, 2002, 07:11 AM
#11
PowerPoster
Oh, right, yeah.
I'll shut up now... 
I completely misread your last post anyway.
I think I need a beer....
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Jan 9th, 2002, 07:13 AM
#12
Thread Starter
PowerPoster
Anyways thanks a lot.
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
|