Hello everyone!
I've been trying to compare two text files line by line but I was only able to compare the file lengths. I'm creating a dance mat game and I have a text file of the steps that should be taken to get a perfect score and a text file of the actual steps taken by the user. Each text file contains a time stamp and a binary value indicating which arrow was stepped on. I'm using streamreader and streamwriter to write and read the text files.
Please let me know if how I can modify my code to make it compare the two text files line by line! Thanks!!Code:Private Sub Score_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim GameScore As String = "C:\SavedGame.txt" If System.IO.File.Exists(GameScore) = True Then Dim objReader As New System.IO.StreamReader(GameScore) ValueBox.Text = objReader.ReadToEnd objReader.Close() End If Dim intLines As Integer = ValueBox.Lines.Length ScoreBox.Text = intLines Dim Survive As String = "C:\I_Will_Survive.txt" Dim intLinesSurvive As Integer = PointsPossibleBox.Lines.Length PercentageBox.Text = (intLines / intLinesSurvive) * 100 Dim f1 As New IO.StreamReader(GameScore) Dim f2 As New IO.StreamReader(Survive) CorrectSteps.Text = f2.ReadToEnd Dim LineNum As Integer Do While f1.Peek <> -1 And f2.Peek <> -1 'loop while there is stuff in the files LineNum += 1 Dim f1Line As String = f1.ReadLine Dim f2line As String = f2.ReadLine If LineNum = Survive Then If f1Line = f2line Then PercentageBox.Text = (f1Line / f2line) End If End If Loop End Sub




Reply With Quote