Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class EnglishGame
  2.  
  3.     'Initialise Variables
  4.  
  5.     Dim TheGuessWord() As Char
  6.     'Stores the six letter word used’
  7.    Dim TheAreaWhereTheGuessIsStored() As Char
  8.     'Stores the detector allowing the player to win’
  9.    Dim Guess As Char
  10.     'Stores the letter the player guessed’
  11.    Dim GuessesLeft As Integer
  12.     'Stores the number of guesses a player has left’
  13.    Dim ThePossibleWords() As String
  14.     'Stores the words that are possible’
  15.    Dim TheRandomNumber As Integer
  16.     'Stores a randomly generated number that selects the word used’
  17.    Dim DidYouWin As Boolean
  18.     'Determines whether the player won or not’
  19.    Dim Blanks() As Char
  20.     'Shows the player a series of 6 blanks to slowly be replaced by letters’
  21.    Dim Counter2 As Integer
  22.     'counter 2'
  23.    Private RandomNumber As New Random
  24.     'generates a random number'
  25.  
  26.  
  27.     'Starts the programme'
  28.    Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
  29.         GuessLabel.Text = "_ _ _ _ _ _"
  30.         GuessButton.Enabled = True
  31.         'set ThePossibleWords
  32.        ThePossibleWords = {"absurd", "common", "carpet", "damson", "escape", "eating", "factor", "guitar", "magnet", "magpie"}
  33.  
  34.         'Sets number of guesses and the winning parameters as well as lays the foudation for guessing
  35.        GuessesLeft = 10
  36.         TheAreaWhereTheGuessIsStored = "______"
  37.         Blanks = "_ _ _ _ _ _"
  38.  
  39.         'Generate Random Number
  40.        TheRandomNumber = RandomNumber.Next(10)
  41.  
  42.         'sets word'
  43.        TheGuessWord = ThePossibleWords(TheRandomNumber)
  44.  
  45.         'test MsgBox, uncomment if it needs to be used to test
  46.        'MsgBox(TheGuessWord)
  47.  
  48.  
  49.  
  50.  
  51.     End Sub
  52.  
  53.     Private Sub GuessBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GuessBox.Click
  54.         'Makes a message inside the textbox disappear on click
  55.        GuessBox.Text = " "
  56.  
  57.     End Sub
  58.  
  59.     Private Sub GuessButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuessButton.Click
  60.  
  61.  
  62.         'fills in the blanks according to the guess imputed
  63.        Guess = GuessBox.Text
  64.         Dim Counter As Integer
  65.         Counter = 0
  66.         DidYouWin = False
  67.  
  68.         For Each N In TheGuessWord
  69.  
  70.             If N = Guess Then
  71.                 TheAreaWhereTheGuessIsStored(Counter2) = N
  72.                 DidYouWin = True
  73.  
  74.                 'uncomment if testing required
  75.                'MsgBox(TheAreaWhereTheGuessIsStored)
  76.  
  77.  
  78.             End If
  79.  
  80.             Counter2 = Counter2 + 1
  81.         Next
  82.  
  83.         For Each C In TheGuessWord
  84.             Counter2 = 0
  85.             If C = Guess Then
  86.                 Blanks(Counter * 2) = C
  87.                 DidYouWin = True
  88.  
  89.                 'uncomment if testing required
  90.                ' MsgBox(TheAreaWhereTheGuessIsStored)
  91.  
  92.                 GuessLabel.Text = Blanks
  93.  
  94.             End If
  95.  
  96.             Counter = Counter + 1
  97.             'uncomment for testing
  98.            'MsgBox(Counter & "  " & Counter2)
  99.        Next
  100.  
  101.         If DidYouWin = False Then
  102.             GuessesLeft -= 1
  103.             GuessLabel2.Text = GuessesLeft
  104.         End If
  105.  
  106.  
  107.         'Helps the player know if they have won or lost
  108.        If GuessesLeft <= 0 Then
  109.             MsgBox("You Lose " & TheGuessWord & " was The word")
  110.             MsgBox("try again")
  111.             GuessButton.Enabled = False
  112.         End If
  113.  
  114.         If TheAreaWhereTheGuessIsStored = TheGuessWord Then
  115.             MsgBox("You Win, Yay!!!!")
  116.             GuessButton.Enabled = False
  117.         End If
  118.  
  119.     End Sub
  120.  
  121.     Private Sub GuessLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuessLabel.Click
  122.  
  123.     End Sub
  124. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement