title: Is there a way to import text file to datagridview in vb.net
body: <p>Good day, i am importing text file to datagridview and i want to have the output like this</p>
  <h2>LOT ADDRESS  |  NAME   | METER NUMBER</h2>
  <p>0123RR ROAD 6 | DOE, JOHN | 123ABC456789</p>
  <p>text file looks like this</p>
  <p>0123RR ROAD 6            DOE, JOHN  123ABC456789</p>
  <p>the character count from address to name is 25 and 10 from name to meter number.</p>
  <p>my code looks like this</p>
  <pre><code>    Dim lines() As String
      Dim vals() As String
      OpenFileDialog1.Filter = &quot;TEXT FILE | *.txt |ALL FILES |*.*&quot;
      If OpenFileDialog1.ShowDialog &lt;&gt; Windows.Forms.DialogResult.Cancel Then
          lines = File.ReadAllLines(OpenFileDialog1.FileName)
          For i As Integer = 12 To lines.Length - 1 Step +1
  
              'Dim newlines As String = lines(i).Substring(25, 20)
  
              vals = lines(i).ToString().Split(&quot; &quot;c, StringSplitOptions.RemoveEmptyEntries)
  
  
              Dim row(vals.Length - 1) As String
  
  
              For j As Integer = 0 To vals.Length - 1 Step 2
  
                  row(j) = vals(j).Trim()
  
  
              Next j
              dt.Rows.Add(row)
  
  
          Next i
      End If
  </code></pre>
  <p>Thank you</p>