0% found this document useful (0 votes)
56 views1 page

Public Class Form2

The document describes a rock-paper-scissors game program where: 1) The computer randomly selects rock, paper, or scissors and the results are compared to the player's selection. 2) The program displays who won or if it was a draw depending on the combinations. 3) A "New Game" option resets the selections and display, while an "Exit" option closes the program.

Uploaded by

api-347017345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views1 page

Public Class Form2

The document describes a rock-paper-scissors game program where: 1) The computer randomly selects rock, paper, or scissors and the results are compared to the player's selection. 2) The program displays who won or if it was a draw depending on the combinations. 3) A "New Game" option resets the selections and display, while an "Exit" option closes the program.

Uploaded by

api-347017345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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