My guess is you are creating a zero or negative index. I cannot know where, since I have no idea what are the sizes of your arrays.
YOU however can find this out easily. First of all, the error should tell you what line it happened in. Is there a reason why you did not bother to give us the complete error message? Must we guess?
Finally, you are the one to fix it, since you are the only one who can run your code. (We don't have those arrays.) Learn to use the debugger. It can show you where the error comes from, as well as allow you to see what those variable sizes were when the error occurred.
Best Answer