Advertisement
Guest User

Homeform

a guest
Jun 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.96 KB | None | 0 0
  1. Public Class HomeForm
  2.  
  3.     Private Sub btnStartGame_Click(sender As Object, e As EventArgs) Handles btnStartGame.Click 'When The Button Start Game is Clicked
  4.         MemoryGame.StartGame() 'From the form "Memory Game" run the subroutine "startgame()" which will load the game
  5.         Me.Hide() 'hide this form (HomeForm)
  6.         MemoryGame.Show() 'Show the "MemoryGame" form
  7.     End Sub
  8.  
  9.     Private Sub btnLeaderboard_Click(sender As Object, e As EventArgs) Handles btnLeaderboard.Click 'When the Button "Leaderboard" is clicked
  10.         Leaderboard.Show() 'Show the leaderboard form
  11.         Me.Hide() ' hide this form (Home Form)
  12.     End Sub
  13.  
  14.     Private Sub HomeForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'When the program first runs, (The homeform loads) do the following:
  15.         Dim NewUser
  16.         NewUser = MsgBox("Is this your first time using this program?", vbYesNo + vbQuestion, "MemoryGame") 'Create a message for the user which asks them if they are new or not
  17.         If NewUser = vbYes Then 'if the user responds with "Yes" they are new to the program and willtherefore need to know how to play
  18.             btnStartGame.Enabled = False 'Disable the button which allows the game to start (this will later be enabled when the user goes through the how to play screen)
  19.             MsgBox("Please go through HowToPlay before starting the game") 'Create message box that informs the user to click the how to play button to start the game
  20.         Else
  21.             Exit Sub 'Or else if the user knows how to play, do nothing - exit the subroutine
  22.         End If
  23.     End Sub
  24.  
  25.     Public Sub ExitProgram() 'Subroutine to Quit the Game when called
  26.         Dim UserPreference 'Creating a variable which stores the user response or "user preference"
  27.         UserPreference = MsgBox("Are you sure you want to exit?", vbYesNo + vbQuestion, "MemoryGame") 'creates an input box where the user needs to confirm if they really want to exit or not - this saves misclicks or accidents
  28.         If UserPreference = vbYes Then 'if they respond with yes then do the following.
  29.             Application.Exit() ' quit the program
  30.         Else
  31.             Exit Sub ' or else if they say no they dont want to quit, do nothing
  32.         End If
  33.     End Sub
  34.  
  35.     Public Sub HowToPlay() 'Subroutine which will open The How To play screen when called
  36.         btnStartGame.Enabled = True 'Saying that the user has seen how to play and is now ready to play the game
  37.         Help.Show() 'shw the Help form
  38.         Me.Hide() ' hide this form
  39.     End Sub
  40.  
  41.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click 'When the button EXIT is clicked
  42.         ExitProgram() 'run the subroutine "ExitProgram" which exits the program
  43.     End Sub
  44.  
  45.     Private Sub btnHelp_Click(sender As Object, e As EventArgs) Handles btnHelp.Click 'When the button HELP is clicked
  46.         HowToPlay() 'run the subroutine HowToPlay which loads the Help Form
  47.     End Sub
  48. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement