i had another question when i read a file like this:
i need the program to search from the top of the text file and not where you stopped:
Dim FS As New FileStream("First_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile As New StreamReader(FS) 'Create an instance of StreamReader to read from a file.
Dim FS2 As New FileStream("Second_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile2 As New StreamReader(FS2) 'Create an instance of StreamReader to read from a file.
Dim FS3 As New FileStream("Third_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile3 As New StreamReader(FS3) 'Create an instance of StreamReader to read from a file.
Dim FS4 As New FileStream("Fourth_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile4 As New StreamReader(FS4) 'Create an instance of StreamReader to read from a file.
Dim temp As String
Do While textfile.Peek > -1 'keeps reading file while NOT end of file
temp = textfile.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player1"
End If
Loop
Do While textfile2.Peek > -1 'keeps reading file while NOT end of file
temp = textfile2.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player2"
End If
Loop
Do While textfile3.Peek > -1 'keeps reading file while NOT end of file
temp = textfile3.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player3"
End If
Loop
Do While textfile4.Peek > -1 'keeps reading file while NOT end of file
temp = textfile4.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player4"
End If
Loop
'this is where i have the problems, i do have more code, but this is just a part of the code
'if the user landed on any oof the propertys before reading railroad, it won't find it in the file, thus not changing numberofrailroadowned, which will change the amount the user has to pay
If player = "player1" And propertys = "Reading Railroad" Then
Do While textfile.Peek > -1 'keeps reading file while NOT end of file
temp = textfile.ReadLine() 'reads a line from file and adds to list box
If temp = "Pennsylvania Railroad" Then
numberofrailroadowned += 1
ElseIf temp = "B & O Railroad" Then
numberofrailroadowned += 1
ElseIf temp = "Short Line" Then
numberofrailroadowned += 1
End If
i need the program to search from the top of the text file and not where you stopped:
Dim FS As New FileStream("First_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile As New StreamReader(FS) 'Create an instance of StreamReader to read from a file.
Dim FS2 As New FileStream("Second_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile2 As New StreamReader(FS2) 'Create an instance of StreamReader to read from a file.
Dim FS3 As New FileStream("Third_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile3 As New StreamReader(FS3) 'Create an instance of StreamReader to read from a file.
Dim FS4 As New FileStream("Fourth_Player_Properties.txt", FileMode.Open, FileAccess.Read)
Dim textfile4 As New StreamReader(FS4) 'Create an instance of StreamReader to read from a file.
Dim temp As String
Do While textfile.Peek > -1 'keeps reading file while NOT end of file
temp = textfile.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player1"
End If
Loop
Do While textfile2.Peek > -1 'keeps reading file while NOT end of file
temp = textfile2.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player2"
End If
Loop
Do While textfile3.Peek > -1 'keeps reading file while NOT end of file
temp = textfile3.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player3"
End If
Loop
Do While textfile4.Peek > -1 'keeps reading file while NOT end of file
temp = textfile4.ReadLine() 'reads a line from file and adds to list box
If temp = "Reading Railroad" Then
player = "player4"
End If
Loop
'this is where i have the problems, i do have more code, but this is just a part of the code
'if the user landed on any oof the propertys before reading railroad, it won't find it in the file, thus not changing numberofrailroadowned, which will change the amount the user has to pay
If player = "player1" And propertys = "Reading Railroad" Then
Do While textfile.Peek > -1 'keeps reading file while NOT end of file
temp = textfile.ReadLine() 'reads a line from file and adds to list box
If temp = "Pennsylvania Railroad" Then
numberofrailroadowned += 1
ElseIf temp = "B & O Railroad" Then
numberofrailroadowned += 1
ElseIf temp = "Short Line" Then
numberofrailroadowned += 1
End If