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)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That means that your
RichTextBox1has no lines in it. Replace that with: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.