Problem Updating File

RunToTheHills
RunToTheHills used Ask the Experts™
on
I'm using VB6.

I am reading and writing to a text file (containing the high score of a game).

The problem is: if the high score is 99 and i try to save the new high score as 100 , it will not do it, for some reason,it is just looking at the first 2 numbers. and 10 is smaller than 99.

here is the code i'm using:

Private Sub Command1_Click()
If Text1.Text > Label1.Caption Then

Open "C:\WINDOWS\Desktop\hisc.txt" For Output As #1
Write #1, Text1.Text
Close #1
Else
MsgBox "you didn't beat the high score"
End If


Dim HighScore
Open "C:\WINDOWS\Desktop\hisc.txt" For Input As #1
Input #1, HighScore
Label1.Caption = HighScore
Close #1
End Sub

Private Sub Form_Load()
Dim HighScore
Open "C:\WINDOWS\Desktop\hisc.txt" For Input As #1
Input #1, HighScore
Label1.Caption = HighScore
Close #1
End Sub
__________________________________________________________



if anyone can help, i would appreciate it.

thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You are doing string comparisons.  Use the value instead.
if val(Text1.Text) > val(Label1.Caption) Then

If that doesn't work, the only other thing I can suggest is perhaps the Text1 has a maxlength of 2.  Get rid of the maxlength and see if you encounter the same problem.

Author

Commented:
Thanks twalgrave.

that fixed it.

have a happy new year!

You too!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial