subscript out of range

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
shibby
Newbie
Posts: 5
Joined: Fri Oct 28, 2005 3:25 pm

subscript out of range

Post by shibby »

OK, i got a question. What does subscript out of range mean?
User avatar
Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:

Arrays

Post by Zim »

It means you have an array and it has a certain dimension (the maximum number of elements in the array) and something in your program is trying to use or assign an element beyond or larger than that. For example:

Code: Select all

DIM x(25)
y=x(27)=3
would generate such an error.

Sometimes a misplaced parenthesis "(" in a program can make BASIC think you're refering to an array when you never intended to, thus causing an array subscript error.

Also, in BASIC you can refer to the first 10 elements of an array without actually using DIM first, but that's not good programming practice.
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: Arrays

Post by moneo »

[quote="Zim"].....
For example:

Code: Select all

DIM x(25)
y=x(27)=3
would generate such an error.

Ooops, I'm sure you meant:

Code: Select all

x(27)=3
*****
Post Reply