R
RallyDSM
Hello,
I'm currently trying to read a .CSV file and get all the data into an
array so I can work with it in the program.
Here is what I currently have.
Private Sub IntializeData()
Dim AL As New ArrayList
Dim sr As IO.StreamReader
'first, let's open the file
sr = IO.File.OpenText("csvstocks.txt")
Dim Entry As String
Do
Entry = sr.ReadLine
If Not Entry Is Nothing Then
Dim B
Dim data() As String = Split(Entry, ",")
B.stock = data(0)
B.numShares = data(1)
B.datePurchased = data(2)
B.purchasePrice = data(3)
B.currentPrice = data(4)
AL.Add(B)
End If
Loop Until Entry = Nothing
End Sub
I got most of this code from another post on the board, what it does is
read the first line of the .CSV into an array, which is perfect, but
then it crashes.
How do I get all lines into the array? And then when I do get that
part, can I add stuff together by doing.
B.currentPrice(1) + B.currentPrice(2)
Thanks in advance.
I'm currently trying to read a .CSV file and get all the data into an
array so I can work with it in the program.
Here is what I currently have.
Private Sub IntializeData()
Dim AL As New ArrayList
Dim sr As IO.StreamReader
'first, let's open the file
sr = IO.File.OpenText("csvstocks.txt")
Dim Entry As String
Do
Entry = sr.ReadLine
If Not Entry Is Nothing Then
Dim B
Dim data() As String = Split(Entry, ",")
B.stock = data(0)
B.numShares = data(1)
B.datePurchased = data(2)
B.purchasePrice = data(3)
B.currentPrice = data(4)
AL.Add(B)
End If
Loop Until Entry = Nothing
End Sub
I got most of this code from another post on the board, what it does is
read the first line of the .CSV into an array, which is perfect, but
then it crashes.
How do I get all lines into the array? And then when I do get that
part, can I add stuff together by doing.
B.currentPrice(1) + B.currentPrice(2)
Thanks in advance.