VERSION 2.00
Begin Form Form1 
   AutoRedraw      =   -1  'True
   Caption         =   "Guess the Random Number"
   ClientHeight    =   4110
   ClientLeft      =   1095
   ClientTop       =   1410
   ClientWidth     =   7365
   Height          =   4515
   Left            =   1035
   LinkMode        =   1  'Source
   LinkTopic       =   "Form1"
   ScaleHeight     =   4110
   ScaleWidth      =   7365
   Top             =   1065
   Width           =   7485
   Begin PictureBox Picture1 
      Height          =   1935
      Left            =   240
      ScaleHeight     =   1905
      ScaleWidth      =   2025
      TabIndex        =   3
      Top             =   120
      Width           =   2055
   End
   Begin CommandButton Command1 
      Caption         =   "Exit"
      Height          =   620
      Left            =   3480
      TabIndex        =   2
      Top             =   2880
      Width           =   1215
   End
   Begin TextBox Text1 
      FontBold        =   -1  'True
      FontItalic      =   0   'False
      FontName        =   "MS Sans Serif"
      FontSize        =   12
      FontStrikethru  =   0   'False
      FontUnderline   =   0   'False
      Height          =   620
      Left            =   3480
      TabIndex        =   0
      Top             =   960
      Width           =   1215
   End
   Begin Label Label1 
      Caption         =   "Guess a number between 1 and 100.  Make your entry in the box  below."
      FontBold        =   -1  'True
      FontItalic      =   0   'False
      FontName        =   "MS Sans Serif"
      FontSize        =   9.75
      FontStrikethru  =   0   'False
      FontUnderline   =   0   'False
      Height          =   620
      Left            =   2520
      TabIndex        =   1
      Top             =   120
      Width           =   3975
   End
End
Dim Target As Integer  'Stores the random number
Dim TotGames As Integer, TotGuesses As Integer
Dim Best As Integer, Worst As Integer

Sub Command1_Click ()
    End
End Sub

Sub Form_Load ()
    Randomize
    Target = Fix(100 * Rnd) + 1
    Form1.Cls
    Picture1.Visible = False
End Sub

Sub Recap (NumOfGuesses)
    
    'Supplied most of the code here without using the code provided
    
    
    Dim Response As Integer
    Picture1.Visible = True
    
    'Increment the TotGames & TotGuesses
    TotGames = TotGames + 1
    TotGuesses = TotGuesses + NumOfGuesses

    'Determine the Best & Worst Games so far
    If TotGames = 1 Then
        Best = NumOfGuesses
        Worst = NumOfGuesses
    Else
        If NumOfGuesses < Best Then
            Best = NumOfGuesses
        End If
        If NumOfGuesses > Worst Then
            Worst = NumOfGuesses
        End If
    End If

    'Display results in the Recap picture box
    Picture1.Print "           RECAP"
    Picture1.Print
    Picture1.Print " Total Games = "; TotGames
    Picture1.Print
    Picture1.Print " Avg. Score =  "; Format(TotGuesses / TotGames, "##.##")
    Picture1.Print
    Picture1.Print " Best Game = "; Best
    Picture1.Print
    Picture1.Print " Worst Game = "; Worst
    
    'To continue or not continue(user determine's here)
    Response = MsgBox("Play again?", 4, "Game Over")
    If Response = 6 Then
        Picture1.Cls
        Picture1.Visible = False
    Else
        End
    End If
End Sub

Sub Text1_KeyPress (KeyAscii As Integer)
    Static k As Integer                ' Counter for number of tries
    Dim Guess As Integer               ' Stores user's last guess
    Dim Mess As String                 ' Stores message for message box
    If KeyAscii <> 13 Then Exit Sub    ' Check for 
    Guess = Val(Text1.Text)            ' Assign user's number to Guess
    Text1.Text = ""                    ' Blank out the Text box
    k = k + 1                          ' Count how many guesses
    
    If Guess < 1 Or Guess > 100 Then   ' Check for legal guess
       Text1.Text = ""
       Mess = "Must be integer between 1 and 100"
       MsgBox Mess, 0, "Error!"        ' Display message box for error
       Exit Sub
    End If
    
    If Guess < Target Then
       Beep
       Form1.Print Guess; " is low, guess again"
    ElseIf Guess > Target Then
       Beep: Beep: Beep: Beep: Beep
       Form1.Print Guess; " is high, guess again"
    Else
       Mess = Str$(Guess) + " is right. It took you " + Str$(k) + " tries"
       MsgBox Mess, 0, "Victory!"     ' Display victory message
       
'Call the Recap procedure here
       Call Recap(k)
       
       k = 0                          ' Set counter back to zero
       Call Form_Load                 ' Load form to start again
    End If
End Sub