IndexOutofRangeException was unhandled
Posted on 2006-06-14
I am having a problem with my program. I recently took on the task of trying to create a Windows form program. The back end code was already written by somebody else, but he wrote everything in a module. He didn't make things object oriented or easy to use, so now I am running into problems nearing the end of this program. I recently ran into a "IndexOutofRangeException was unhandled" problem and it's stopping me from finishing the program. The following was said in the Troubleshooting tips section:
1)Make sure that the maximum index on a list is less than the list size.
2)Make sure data column names are correct.
3) Make sure the index is not a negative number
4) Get general help for this section.
Can anybody help?
Below is the code in the sub section in the module that was handed to me.
Sub MoveIt(ByVal inpStartLoc As Integer, ByVal outLength As Integer, ByRef buildString As String)
Dim intFrom As Integer = inpStartLoc - 1
Dim intTo As Integer = intFrom + outLength - 1
For k As Integer = intFrom To intTo - 1
buildString &= strInput(k)
I declared strInput at the top of the module as the following which is not in the sub above.
Dim strInput As String = ""
Can anybody help please? Thank you!