Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Public Class Form1

Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnGo.Click
Const ROCK As Integer = 1
Const PAPER As Integer = 2
Const SCISSORS As Integer = 3
Dim computerThrow As Integer

Randomize()
computerThrow = Int(3 * Rnd() + 1)

If radRock.Checked And computerThrow = ROCK Then


lb1Winner.Text = "Computer throws Rock. It's a draw!"
ElseIf radRock.Checked And computerThrow = PAPER Then
lb1Winner.Text = "Computer throws Paper. Computer wins!"
ElseIf radRock.Checked And computerThrow = SCISSORS Then
lb1Winner.Text = "Computer throws Scissors. You win!"
End If

If radPaper.Checked And computerThrow = ROCK Then


lb1Winner.Text = "Computer throws Rock. You Win!"
ElseIf radPaper.Checked And computerThrow = PAPER Then
lb1Winner.Text = "Computer throws Paper. It's a draw!"
ElseIf radPaper.Checked And computerThrow = SCISSORS Then
lb1Winner.Text = "Computer throws Scissors. Computer wins!"
End If

If radScissors.Checked And computerThrow = ROCK Then


lb1Winner.Text = "Computer throws Rock. Computer wins!"
ElseIf radScissors.Checked And computerThrow = PAPER Then
lb1Winner.Text = "Computer throws Paper. You win!"
ElseIf radScissors.Checked And computerThrow = SCISSORS Then
lb1Winner.Text = "Computer throws Scissors. It's a draw!"
End If
End Sub

Private Sub NewGameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles NewGameToolStripMenuItem.Click
lb1Winner.Text = Nothing
radRock.Checked = False
radPaper.Checked = False
radScissors.Checked = False
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
End Class

You might also like