|
-
Mar 19th, 2017, 11:04 AM
#6
Re: Index was outside the bounds of the array.
You aren't allowed to attach compiled code, for obvious reasons. Source code files are just text, though, and those are fine on this end.
The problem appears fairly obvious based on the example file you showed. Only the first two columns have values for all rows, so any attempt to check the third or fourth column along with the first or second is certain to fail with the exact error you are showing. Split() will return an array with the number of elements found. In the first several rows, that means that split will return an array with four elements. Accessing any of those four elements is fine. However, for the last several rows, Split will only result in an array with two elements, because there is nothing in the third or fourth element. Any attempt to access the third or fourth element on those lines will give you an Index Out Of Range exception because the array only has two elements.
What the best solution is to this problem is harder to say. You can always check the length of the textLine array, and not do anything with elements beyond the end of the array. Or maybe the real problem is the missing data, in which case you can fix up the lines before doing the rest.
My usual boring signature: Nothing
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|