I have a text file called games.txt that contains the details of many computer game matches. Each line represents:
Player1Score, Player1Name, Player1Age, Player 2Score, Player2Name, Player2Age
Here is an example of 3 lines (there are a total of 150):
1, John, 32, 5, Albert, 54
3 Lisa, 33, 2, Michael, 36
4 Jessica, 24, 1 Robert, 32
I want to assign them to a structure array in which each element has 6 member variables using StreamReader. Here is the structure variable:
Structure gameDetails
Public Player1Score As Integer
Public Player1Name As String
Public Player1Age As Integer
Public Player2Score As Integer
Public Player2Name As String
Public Player2Age As Integer
End Structure
I know that using a comma as a delimiter, I can record each variable as a different element in the array:
Dim game() as String
game() = inFile.ReadLine.Split(","c)
which would result in each element being assigned in this way:
game(0) = 1
game(1) = John
game(2) = 32
Etc..
Is there a way I can directly assign all the member variables to each element? Like maybe each comma separates a member variable, and a new line means a new element? Unfortunately, I am not familiar with the syntax/commands so I do not know how to approach this.
Note that I cannot hard-code anything as the application is designed to take all the data from the .txt.