title: Visual Basic Read File Line by Line storing each Line in str
body: <p>I am trying to loop through the contents of a text file reading the text file line by line. During the looping process there is several times I need to use the files contents.</p>
  
  <pre><code>Dim xRead As System.IO.StreamReader
  xRead = File.OpenText(TextBox3.Text)
  
  Do Until xRead.EndOfStream
    Dim linetext As String = xRead.ReadLine
    Dim aryTextFile() As String = linetext.Split("  ")
  
    Dim firstname As String = Val(aryTextFile(0))
    TextBox1.Text = firstname.ToString
  
    Dim lastname As String = Val(aryTextFile(0))
    TextBox2.Text = lastname.ToString
  Loop
  </code></pre>
  
  <p><strong>Edit:</strong> What I am trying to do is read say the first five items in a text file perform some random processing then read the next 5 lines of the text file.</p>
  
  <p>I would like to be able to use the lines pulled from the text file as separated string variables.</p>