I am trying to write some code to add string arrays (Sitem) into an arraylist (Slist), but for some reason all the items in the arraylist end up containing the same string array (Sitem) values.
Text File excerpt
Runner
Lake
01-04-1994
09:43
Stalk
Pool
03-04-1994
09:46
All Slist items contain the following:
Stalk
Pool
03-04-1994
09:46
Please see my code below, and thank you for any assistance.
Text File excerpt
Runner
Lake
01-04-1994
09:43
Stalk
Pool
03-04-1994
09:46
All Slist items contain the following:
Stalk
Pool
03-04-1994
09:46
Please see my code below, and thank you for any assistance.
VB.NET:
Private Sub ReadFile()
Dim FR As New StreamReader("input.txt")
Dim Sitem(3) As String
Dim Slist As New ArrayList
Do While FR.Peek > -1
Sitem(0) = FR.ReadLine
Sitem(1) = FR.ReadLine
Sitem(2) = FR.ReadLine
Sitem(3) = FR.ReadLine
Slist.Add(Sitem)
Loop
FR.Close()
MsgBox(0)
End Sub