Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# I know this has nothing to do with VB

Posted on 1999-08-03
Medium Priority
131 Views
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.
0
Question by:Praetoria
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 1

Expert Comment

ID: 1529186
Redim a(40)

Then Code
0

LVL 2

Expert Comment

ID: 1529187
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
0

Author Comment

ID: 1529188
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.
0

LVL 18

Accepted Solution

deighton earned 400 total points
ID: 1529189
DIM x(40)   'change this bit
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
0

Author Comment

ID: 1529190
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)
0

LVL 2

Expert Comment

ID: 1529191
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.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
###### Suggested Courses
Course of the Month7 days, 9 hours left to enroll