CODE
Option Explicit On
Option Strict On
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Fills the list box with items, then selects the first item
guessListBox.Items.Add("")
guessListBox.Items.Add("0")
guessListBox.Items.Add("1")
guessListBox.Items.Add("2")
guessListBox.Items.Add("3")
guessListBox.Items.Add("4")
guessListBox.Items.Add("5")
guessListBox.Items.Add("6")
guessListBox.Items.Add("7")
guessListBox.Items.Add("8")
guessListBox.Items.Add("9")
guessListBox.Items.Add("10")
guessListBox.SelectedIndex = 0
End Sub
Private Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
'Display a message indicating if the user guessed the correct number
'times the user selects an incorrect number
Dim randomGenerator As New Random
Dim userChoice As String
Dim computerChoice As Integer
Static numberCorrect As Integer
Static numberIncorrect As Integer
computerChoice = 7
'Saves the user's list box selection, then disables the list box
userChoice = guessListBox.SelectedItem.ToString
guessListBox.Enabled = True
'Display correct and incorrect times a user guesses
'Display appropriate message box
If CDbl(userChoice) = computerChoice Then
numberCorrect = numberCorrect + 1
applePictureBox.SetBounds(0, 0, 0, 0)
MessageBox.Show("Good Job!")
ElseIf CDbl(userChoice) > computerChoice Then
numberIncorrect = numberIncorrect + 1
applePictureBox.SetBounds(0, 0, 0, 5)
MessageBox.Show("Sorry, wrong answer.")
ElseIf CDbl(userChoice) < computerChoice Then
numberIncorrect = numberIncorrect + 1
applePictureBox.SetBounds(0, 0, 0, -5)
MessageBox.Show("Sorry, wrong answer.")
End If
correctLabel.Text = Convert.ToString(numberCorrect)
incorrectLabel.Text = Convert.ToString(numberIncorrect)
End Sub
Private Sub stopButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles stopButton.Click
End Sub
End Class
Mod edit - Added code tags.