I am trying to read selected columns in a text file and getting min and max values of those columns. I can read the first and second column in a sequence, but when I break the sequence i.e. reading first and third or fourth column, I get the error "Index was outside the bounds of the array" .. The selection of the column is in the textbox.
The text file I am reading has columns separated by TAB and Spaces. So the code is replacing all the spaces and double tabs to single TAB to be consistent. Following is the example of text file
Please help me in finding the error as I have to finish this as quick as possible.. Thanks in advance
Code:
Using RECfile As New System.IO.StreamReader("C:\RECEIVER.txt")
Dim maxE As Double = 0
Dim minE As Double = 99999999
Dim maxN As Double = 0
Dim minN As Double = 99999999
Do While RECfile.Peek() <> -1
Dim textline As String() = RECfile.ReadLine().Replace(CChar(vbTab) & CChar(vbTab), vbTab).Split(New Char() {CChar(vbTab)})
If textline(Me.eastval.Text) > maxE Then
maxE = textline(Me.eastval.Text)
Me.MaxvalE.Text = maxE.ToString()
End If
If textline(Me.eastval.Text) < minE Then
minE = textline(Me.eastval.Text)
Me.MinvalE.Text = minE.ToString()
End If
If textline(Me.northval.Text) > maxN Then
maxN = textline(Me.northval.Text)
Me.MaxvalN.Text = maxN.ToString()
End If
If textline(Me.northval.Text) < minN Then
minN = textline(Me.northval.Text)
Me.MinvalN.Text = minN.ToString()
End If
Loop
End Using
Last edited by Learn_VB; Mar 19th, 2017 at 06:17 AM.
Reason: updating with available data file