I got a project I'm working and I need to StreamRead a file into parallel arrays. I have the file being read into a collection and then split by char into different arrays... I think. The file contains info that locks like this -
P_CODE P_DESCRIPT P_INDATE P_QOH P_MIN P_PRICE
11QER/31 Power painter, 15 psi., 3-nozzle 03-Dec-11 8 5 109.99
13-Q2/P2 7.25-in. pwr. saw blade 13-Jan-12 32 15 14.99
14-Q1/L3 9.00-in. pwr. saw blade 13-Jan-12 18 12 17.49.
My code so far looks like this-
Private Sub BtnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRead.Click
Dim Note As New StreamReader(New FileStream(Path, FileMode.OpenOrCreate, FileAccess.Read))
Dim inventory As New List(Of FrmInventory)
Do While Note.Peek <> -1
Dim row As String = Note.ReadLine
Dim columns() As String = row.Split(CChar(" "))
Dim info As New FrmInventory
info.Title = columns(0)
info.Code = columns(1)
info.Descrip = columns(2)
info.InDate = columns(3)
info.QOH = CInt(columns(4))
info.Min = CInt(columns(5))
info.Price = CDec(columns(6))
Loop
Note.Close()
For Each item In (inventory)
ListBoxInventory.Items.Add(item)
Next
End Sub
My For Each doesn't work and I need to display the arrays in the list box I have on my form. I also need to format each array before I display them. Any help of ideas would be great. Thanks.
P_CODE P_DESCRIPT P_INDATE P_QOH P_MIN P_PRICE
11QER/31 Power painter, 15 psi., 3-nozzle 03-Dec-11 8 5 109.99
13-Q2/P2 7.25-in. pwr. saw blade 13-Jan-12 32 15 14.99
14-Q1/L3 9.00-in. pwr. saw blade 13-Jan-12 18 12 17.49.
My code so far looks like this-
Private Sub BtnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRead.Click
Dim Note As New StreamReader(New FileStream(Path, FileMode.OpenOrCreate, FileAccess.Read))
Dim inventory As New List(Of FrmInventory)
Do While Note.Peek <> -1
Dim row As String = Note.ReadLine
Dim columns() As String = row.Split(CChar(" "))
Dim info As New FrmInventory
info.Title = columns(0)
info.Code = columns(1)
info.Descrip = columns(2)
info.InDate = columns(3)
info.QOH = CInt(columns(4))
info.Min = CInt(columns(5))
info.Price = CDec(columns(6))
Loop
Note.Close()
For Each item In (inventory)
ListBoxInventory.Items.Add(item)
Next
End Sub
My For Each doesn't work and I need to display the arrays in the list box I have on my form. I also need to format each array before I display them. Any help of ideas would be great. Thanks.