title: i'm trying to load a text file into an array. in vb
body: <p>this is what i have so far</p>
  
  <p>the array size is (199,2)</p>
  
  <p>the file holds lines that look like this: Canada,34026478,12938494
                                            USA,3377786,5345678</p>
  
  <pre><code>Sub LoadFromFile(filename As String)
  
      Dim Reader As StreamReader = File.OpenText(filename)
      Dim Currentline As String
      Dim lineArray() As String
  
      Do While Reader.EndOfStream = False
          Currentline = Reader.ReadLine
          lineArray = Currentline.Split(","c)
      Loop
  
      Using sr As StreamReader = New StreamReader(filename)
          Do While sr.Peek() &gt;= 0
              For Each c As Char In sr.ReadLine.Split
                  Try
                      ValuesFromFile(y, x) = CStr(Integer.Parse(c))
                  Catch ex As Exception 'i assume this is the only possible error, but we could be out of bounds due to assuming the actual size of the file/line... catch specific exceptions as necessary'
                  End Try
                  y += 1
              Next
              x += 1
              y = 0
          Loop
      End Using
  
  
  
      Reader.Close()
  End Sub
  </code></pre>