VB Code:
'include Microsoft Scripting Runtime
Public fsObj As FileSystemObject
'in form load
Set fsObj = New FileSystemObject
Public Sub SaveScore(Name As String, Score As Integer)
Dim ts As TextStream
Set ts = fsObj.OpenTextFile(App.Path & "\score.ini", ForAppending)
ts.WriteLine (Name & " = " & Score)
ts.Close
Set ts = Nothing
End Sub
Public Sub LoadScore(Name As String, Score As Integer)
Dim ts As TextStream
Listbox1.Clear
If fsObj.FileExists(App.Path & "\score.ini") Then
Set ts = fsObj.OpenTextFile(App.Path & "\score.ini", ForReading)
Do While Not ts.AtEndOfStream
Listbox1.Add ts.ReadLine
Loop
ts.Close
Set ts = Nothing
Else
MsgBox "No high scores yet"
End If
End Sub