I am getting an Indexing error on my code but I am very sure that there is data inside the location I am trying to print.
Below is the problem code.
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim seriesName As String = ComboBox2.SelectedItem.ToString()
Dim seriesLocation As String = "excelFiles/seriesID.csv"
Dim seriesData = File.ReadAllText(seriesLocation)
Dim seriesRows = Split(seriesData, vbCrLf)
For Each line In seriesRows
Dim seriesItem = Split(line, ",")
If seriesItem(1) = seriesName Then '<--- this is the error line
TextBox2.Text += seriesItem(2) + ","
End If
Next
End Sub
I have used this code in a similar sub which works, and have accessed the file in an another but I just can not understand why this isn't working on this one.
I am trying to use the item inside a combo-box and compare it to data from a CSV stored in an array.
I have added some pictures below showing the error and what happens when I try to display the location.
Difference in Printing Location "0" (top) and "1" (bottom)
The only difference is that I have changed seriesItem(1) to seriesItem(0)
Thanks for your help