Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiler Error: Subscript out of range?

Status
Not open for further replies.

analyzergeek

Technical User
Feb 19, 2009
2
US
I'm not a professional programmer, however, I've been tasked with writing 3 small programs for an on-stream gas chromatograph using something the analyzer vendor calls MaxBasic, which is a subset of Visual Basic 3.0. After extracting data from two tables in a database as SnapShots, and decalring multiple variable arrays with ReDim(# To #) statements, I attemted to program math caculations using a For..Next operation to step through the objects in my table and do the math. For some reason, I'm getting the error, "Subscript Out of Range."

In the ReDim statements, I basically set a range from (1 To 14) after each of the variable names, because that is how many values that will be acted upon with the math calculations. I also Declared a Dim statement, Dim i = intNOP As Long: intNOP = arg0 'arg0 is the number of buffered results. I use this in the For...Next operation, (ex. For i = 1 + intNOP, Math Calculations, Next i) to do the math on all the values in the designated array.

Basically, I don't know enough to know why I'm getting this alarm and where to look. If anyone has seen this before and can give me some advice, I would certainly appreciate it.

Blessings to all!!
 
I figured out the problem. In the ReDim declarations I had set the upper limit too low. I needed to calculate 14 results in a table and I had set the ReDim declaration from (1 To 14). For some reason the setup parameter box on the editor/compiler would not take the integer 14 in the iarg0 box. When I changed it to 13 it worked. The only way I could get 14 to work was to change the range on the ReDim declaration to (1 To 15). The program then ran, did all the calculations and updated a new result table with the 14 new values.

Thanks for the input!

Blessings to all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top