Computer Science Canada "Array Subscript out of Range"... I'm stumped. |
Author: | ZeroPaladn [ Thu Jan 11, 2007 2:42 pm ] | ||||
Post subject: | "Array Subscript out of Range"... I'm stumped. | ||||
This is a library program (for my [FP] for school and CompSci) and im puzzled. I load a file with 15 strings in it, like this. [syntax=".txt file"]Billy Talent II,Billy Talent,001 Crisis,Alexisonfire,002 Hybrid Theory,Linkin Park,003 The Sufferer and the Witness,Rise Against,004 Meteora,Linkin Park,005[/syntax] It all loads fine, but when i go to add new item to this list, it searches through the available enteries that i store into a flexible array upon loading the form. when it searches through the array and comparing it to the text inside the text boxes in my form, i get the array subscript out of range thingy. I'm stumped, cause i is used in the size of the array along with the ending point for the for loop.
Can anyone shed some light on this, greatly apreciated. |
Author: | Silent Avenger [ Thu Jan 11, 2007 4:13 pm ] |
Post subject: | Re: "Array Subscript out of Range"... I'm stumped. |
Try putting a stop in and checking what the value for I is when you check the variable. Also make sure that the variable i is not being changed or used for anything else between the time you make the size of the array and when you do the decision statement. |
Author: | Monstrosity_ [ Thu Jan 11, 2007 11:21 pm ] |
Post subject: | Re: "Array Subscript out of Range"... I'm stumped. |
ZeroPaladn @ Thu Jan 11, 2007 3:42 pm wrote: It all loads fine, but when i go to add new item to this list, it searches through the available enteries that i store into a flexible array upon loading the form. when it searches through the array and comparing it to the text inside the text boxes in my form, i get the array subscript out of range thingy. I'm stumped, cause i is used in the size of the array along with the ending point for the for loop.
Yup, and since the only thing in that line thats changing is i.. so this will prompt you to go look where i was last modified. Oh, look at that.. after each line you increment i by one so your redim statement works on the next iteration. Also note that you probably didn't mean to use i as the index, perhaps your loop variable j was the right choice? Either case you need to fix that i value. |
Author: | ZeroPaladn [ Fri Jan 12, 2007 8:36 am ] | ||||||||
Post subject: | Re: "Array Subscript out of Range"... I'm stumped. | ||||||||
i was last modified during the Form_Load, when I have to ReDim the array to fit more enteries. The thing is, i gets to 5 from the file that I provided. Yet when I trace executed, i = 5. Yet it is 5 when the array get our of range. Thus is why I'm stumped. The only time i is modified is when I have to ReDim the array so it can fit the new entry, but I never get to that part with the error that I get. I'll post when I get it. EDIT Found the stupidest error ever...
One down, but the error still remains. now j does out of range at the same area. Again I'm stumped. At least I got rid of the dumb error ![]() EDIT AGAIN Joy, found the error!
But it is not the end...
Grrr... it just never ends! ...EDIT... Can't write to a file when I'm opening it for input...
Done and Done. Thanks for the help guys! |