title: Comparing Best Times not always working correctly and not sure why
body: <p>This is for VB.NET 2017. I am creating a program and keeping score with the best time. The timer in the program runs like a stopwatch. I would like at the end to compare the best record from a past game with the current time of a new game. If the new game has a faster time then I would like to replace it on the data file. I can do that just fine but sometimes it will put a slower time ahead of the fastest time. I have tried multiple scenarios and cannot get it consistent. If anyone could help that would be appreciated very much. I have some message boxes so I can see some outcomes. They will be commented out later when it is working properly.</p>
  
  <pre><code> If TotalBalls = 2 And SelectPoison = 2 Then
          tmrTime.Enabled = False
          CurrentScore = lblTime.Text
          MsgBox("You win.")
          '''''''''''''''''''''''''''''''''''''''''''''''''''
          '   CurrentScore = lblTime.Text
          MsgBox("Current Time is " &amp; CurrentScore)
          NewScoreCheck = String.Compare(CurrentScore, RecordHighScore)
          MsgBox(NEwScoreCheck)
          'NewScoreCheck will be less than 0 if CurrentScore is less (alphabetically) than RecordhighScore
          'NewScoreCheck will be greater than 0 if RecordHighSchore is greater than CurrentScore
  
          If NewScoreCheck &lt; 0 Then
  
  
              MsgBox(CurrentScore)
              Try
                  MsgBox("In the try statement. Writing new time")
                  Dim FileWrite As System.IO.StreamWriter
                  FileWrite = New System.IO.StreamWriter("PoisonHighScore.TXT", False)
                  FileWrite.WriteLine(CurrentScore)
                  FileWrite.Close()
              Catch
                  MsgBox("Saving error")
              End Try
  
          Else
              MsgBox("Not the fastest time.")
  
          End If
  
      Else
          MsgBox("You lose.")
  
  
      End If
  
      strExit = MsgBox("Do you want to play again?", vbYesNo)
  
      If strExit = vbYes Then
          Application.Restart()
      End If
  End Sub
  </code></pre>
  
  <p>Edit 1: I am using some variables as TimeSpan which is why I have the values CurrentScore and RecordHighScore as Strings. When I am using TimeSpan it will not store as an Integer and will return an error. I am looking for a way to compare two times but need to store them in such a way that they can be compared which is why I used the compare string method mentioned above. I understand after looking at the solution below as to why I cannot. My question now becomes how do I store them since it cannot be stored as double, single, or integer?</p>
  
  <p>To make it a little more clear think of two racers who finish with two different times and those times being unpredictable. The fastest time would win and we would write to the text file (which I know how to do) the time of the winner.</p>
  
  <p>P.S. I have also tried the CInt(CurrentScore) &lt; CInt(RecordHighScore) but that just returns an error too. Any help again would be greatly appreciated and thank you for taking the time to help me with this. </p>