As of now I am trying to read in a text file that is tab delimited with uneven columns. My problem is that when I try to split the file into respective lines, I get an "out of array bound" error. I know this is due to have a NULL value in certain row/columns places. Is there a way to just read through each row instead of relying on each column to have a value in it? I have attached my input file for easy viewing.
Here is my code thus far:
Dim infile As IO.StreamReader = IO.File.OpenText("input.txt") Dim lines() As String Dim outFile As IO.StreamWriter = IO.File.CreateText("out.txt") Dim col1 As Char Dim col2 As String Dim col3 As String Dim col4 As String Dim col5 As String For Each line In IO.File.ReadAllLines("input.txt") lines = infile.ReadLine.Split(vbTab) col1 = lines(0) col2 = lines(1) col3 = lines(2) col4 = lines(3) col5 = lines(4) 'Error here With outFile .WriteLine(col1) .WriteLine(col2) .WriteLine(col3) .WriteLine(col4) .WriteLine(col5) End With Next