Im getting this error message randomly:
Index was outside the bounds of the array.
And it points to this line:
Dim placename As String = RichTextBox1.Lines(0)
Im getting this error message randomly:
Index was outside the bounds of the array.
And it points to this line:
Dim placename As String = RichTextBox1.Lines(0)
That means that your RichTextBox1 has no lines in it. Replace that with...
Dim placename as String
if RichTextBox1.Lines.Count() > 0 then
placename=RichTextBox1.Lines(0)
Else
placename = string.Empty
End if
More Info:
Imagine an array as a street. And each element in the array is a house. If there are 30 houses on the street, and i want to find house number 20, i start at the begining (1) and go up until i reach 20. With an array, 0 is where you start instead of 1, so an array with 30 elements, contains indexes 0-29. Now back to the street analogy. Imagine i go onto the street and ask for house number 31. That house doesnt exist because there is only 30 houses. That is effectively what the program is telling you. It is saying 'There are not enough elements in the array for me to get to the one you asked for'. So you asked for the element 0 in the array of lines, effectively saying 'Give me the first line'. Now, if there are 0 lines in the textbox, then the first line does not exist and you will get this error
Index was outside the bounds of the array
That error message usually means that you have called for an object in the array at a location that is null, or has nothing there. It happens in cases like the following;
myArray = [0,1,2,3];
trace(myArray[6]);
As there is nothing in the array at the index 6, it is outside the bounds. If the array is empty at the time of the call, it will give the error for an object at index 0.
I can't tell any more than that by the amount of code that you posted. Try checking to make sure the array has been populated before that line is called.