I am trying to read in high scores from a text file that look like this
Name1
Score1
Name2
Score2
Name3
Score3
etc.
I can write them out fine, but reading them in I seem to be having a problem with. I have read in the first name ok but when I try to read in the second name, it is giving me the 3rd name. Code below
Can somebody please explain why lblName2 is becoming the fifth line of text instead of the third?Code:Dim objReader As IO.StreamReader = New IO.StreamReader("C:\Users\Karl\Desktop\HighScore.txt") Dim strName As String Dim intNumber As Integer 'Code for Name 1 lblName1.Text = objReader.ReadLine lblName1.Visible = True 'Code for Name 2 intNumber = 0 Do Until intNumber = 2 objReader.ReadLine() strName = objReader.ReadLine intNumber = intNumber + 1 Loop objReader.Close() objReader.Dispose() lblName2.Text = strName lblName2.Visible = True
I realise I have probably not used the correct type of variables but I have only just started learning computing at college so don't bite my head off!
Thanks




Reply With Quote