Praetoria
asked on
I know this has nothing to do with VB
This isn't a question from VB, its about Quick Basic.
I'm trying to insert variables into the name of another variable so that I can create a unique variable name each time it cycles.
E.g
start:
b = 4
va = 1
a(va) = b
b = b + 1
va = va +1
goto start
so that printing a(1) = 4, a(2) = 5 a(3) = 6 ETC
This works fine, except that there is a maximum of 10, so that you can only go up to a(10). However for the purposes of the game I need it to go up to at least 40.
Does ne1 know how I can get it to go higher, I've tried just about everything.
I'm trying to insert variables into the name of another variable so that I can create a unique variable name each time it cycles.
E.g
start:
b = 4
va = 1
a(va) = b
b = b + 1
va = va +1
goto start
so that printing a(1) = 4, a(2) = 5 a(3) = 6 ETC
This works fine, except that there is a maximum of 10, so that you can only go up to a(10). However for the purposes of the game I need it to go up to at least 40.
Does ne1 know how I can get it to go higher, I've tried just about everything.
Before you code Type
Dim a(50)
This will fix it as you using 'a' as an array
and it must be defined if more than 10 elements
Dim a(50)
This will fix it as you using 'a' as an array
and it must be defined if more than 10 elements
ASKER
I tried that but it still came up with Subscript out of range. if it helps here is a copy of the actual code (including suggested fix)
DIM a(40)
CLS
LET a = 0
LET b = 1
start:
LET a = a + 1
LET b = b + 1
LET x(a) = b - says subscript out of range once a > 10
IF a = 40 THEN GOTO printout ELSE GOTO start
printout is just the rest of the program (non-essential for the question.
DIM a(40)
CLS
LET a = 0
LET b = 1
start:
LET a = a + 1
LET b = b + 1
LET x(a) = b - says subscript out of range once a > 10
IF a = 40 THEN GOTO printout ELSE GOTO start
printout is just the rest of the program (non-essential for the question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks guys, its helped a great deal, I've been trying to figure that out for ages. And I've got a huge book on qbasic to help to (tehe)
Sorry, I`m a bit puzzled, in your question you were saying about a(1)=4 a(2)=5 etc.
So my answer was DIM a(50)
you rejected, displayed your code and have changed 'a' for 'x' but still typed DIM a(50)
It dosent appear that my answer was incorrect does it.
So my answer was DIM a(50)
you rejected, displayed your code and have changed 'a' for 'x' but still typed DIM a(50)
It dosent appear that my answer was incorrect does it.
Then Code