|
-
Jan 13th, 2007, 01:36 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Declare array in eVB
Can anyone confirm the correct way of declaring an array in eVB? I recently ported an app from VB6 to eVB.
The following declaration appears in the VB6 app:
Private MyCounter(0 To 30) As Long
I replaced the above declaration with the following in eVB:
Public MyCounter(30) As Long
I also tried the following:
Public MyCounter(30, 30) As Long
Unfortunately I still get an error message in eVB: Subscript out of range: ‘MyCounter’.
Any advice?
Last edited by yolandre; Jan 1st, 2008 at 03:08 AM.
-
Jan 13th, 2007, 01:57 PM
#2
Re: Declare array in eVB
One thing you can do is leave off that "As Long" part. Since every variable in eVB is a Variant, specifying the type does little more than suggest what you expect to put in there. You can assign the value "Blue" to that line, and Blue it will be.
(I don't much like eVB, especially for this reason).
Since I don't like eVB, I haven't worked with it much, and when I did was several years ago. You might try declaring the array with no size, then use ReDim to size it. My thinking is that since all variables are Variants, it might be that you create a variable for the array, and then have to dimension it as the next step.
Just a guess, though.
My usual boring signature: Nothing
 
-
Jan 14th, 2007, 03:46 AM
#3
Frenzied Member
Re: Declare array in eVB
When do you get the error - at declaration or in use?
There is no problem with the declaration - are you sure you are not exceeding the bounds of the array?
Pete
-
Jan 15th, 2007, 12:58 AM
#4
Thread Starter
Addicted Member
Re: Declare array in eVB
The app compiles with no errors, i.e. error occurs during runtime.
-
Jan 15th, 2007, 01:00 AM
#5
-
Jan 15th, 2007, 01:07 AM
#6
Thread Starter
Addicted Member
Re: Declare array in eVB
Been there, done that. It still generates an error...
-
Jan 15th, 2007, 02:48 AM
#7
Frenzied Member
Re: Declare array in eVB
Hi,
if it is a run time error, you are probably addressing outside the array, trying to access element 31.
Put an 'If index >= 30 then' around your array access and see if the error goes away.
Pete
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
|