02-04-2024, 10:47 PM
Looks to me like everything is working as it's supposed to.
You move that DIM up to the start of the program.
Then you have a GOSUB routine that uses it....
Then you ERASE that DIM at the end of that GSOUB routine, before the RETURN...
Then you try and GOSUB back to that routine to use it....
ERROR ERROR ERROR!! You're out of bounds for an array that doesn't exist!!
Now, take that ERASE out of there and run it. You now are getting an ALREADY DEFINED error. This is expected as well:
Trying to DIM an array inside a loop isn't a good idea.
Change that to REDIM, and you're golden.
So my advice here:
1) Get rid of ERASE and CLEAR. This is the type of glitches that are common when you use those commands. Expect to have them pop up a lot on you as you code.
2) Change that DIM to REDIM, since you're going to be remaking this array repeatedly.
3) Then place it wherever the heck you want it.
You move that DIM up to the start of the program.
Then you have a GOSUB routine that uses it....
Then you ERASE that DIM at the end of that GSOUB routine, before the RETURN...
Then you try and GOSUB back to that routine to use it....
ERROR ERROR ERROR!! You're out of bounds for an array that doesn't exist!!
Now, take that ERASE out of there and run it. You now are getting an ALREADY DEFINED error. This is expected as well:
Code: (Select All)
foo
Sub foo
For i = 1 To 10
Dim x(10)
Next
End Sub
Trying to DIM an array inside a loop isn't a good idea.
Change that to REDIM, and you're golden.
So my advice here:
1) Get rid of ERASE and CLEAR. This is the type of glitches that are common when you use those commands. Expect to have them pop up a lot on you as you code.
2) Change that DIM to REDIM, since you're going to be remaking this array repeatedly.
3) Then place it wherever the heck you want it.