Results 1 to 6 of 6

Thread: Index was outside the bounds of the array.

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    5

    Index was outside the bounds of the array.

    Dear All,

    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

    00001111 00002222 00003333 00004444
    194987.5 195012.5 194987.5 195012.5
    195012.5 2003999 195012.5 2003999
    2003999.5 195037.5 2003999 195037.5
    195037.5 195062.5 195037.5 195062.5
    195062.5 195087.5 195062.5 195087.5
    195087.5 195112.5 195087.5 195112.5
    195112.5 195137.5 195112.5 495137.5
    195137.5 195162.5 195137.5 195162.5
    195162.5 194812.5 195162.5 19400012.5
    194837.5 194837.5
    194862.5 194862.5
    194887.5 194887.5
    194912.5 194912.5
    194937.5 194937.5
    12111 12111999.5

    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
    Attached Files Attached Files
    Last edited by Learn_VB; Mar 19th, 2017 at 06:17 AM. Reason: updating with available data file

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width