Private Sub Main1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim MessageResponse As MessageBox
If MessageResponse.Show("Are You Sure You Want To Leave?", "Top Score Scorebook", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.No Then
e.Cancel = True
End If
If GameRun = False Then
Application.Exit()
End If
If GameRun = True Then
Dim MyFile As Object
Dim fs As Object
Dim var1 As String
Dim DataFile
Dim Backup As New Backup()
SaveStats()
fs = CreateObject("Scripting.FileSystemObject")
MyFile = Dir(FileLocation & "*.dat", FileAttribute.Normal)
DataFile = Dir(FileLocation & "\Backup", FileAttribute.Directory)
If DataFile = "" Then
MkDir(FileLocation & "\Backup")
End If
fs.CopyFile(FileLocation & "*.*", FileLocation & "\Backup")
Var = MsgBox("Would You Like To Backup?", MsgBoxStyle.YesNo + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2)
If Var = MsgBoxResult.No Then
Application.Exit()
End If
If Var = MsgBoxResult.Yes Then
Backup.Show()
Exit Sub
End If
On Error GoTo ErrorFix
SaveVars()
SaveData()
SaveBowlingStats()
SaveMatchStats()
SaveHomeTeam()
SaveAwayTeam()
SaveTeamData()
End If
ErrorFix:
If Err.Number = 53 Then
SaveData()
Application.Exit()
End If
End Sub