This document contains code for a rock-paper-scissors game. It defines constants for rock, paper, and scissors and generates a random computer throw. When the user selects rock, paper, or scissors by clicking a button, it compares the selection to the computer's throw and displays the result - whether it's a draw, a win for the user, or a win for the computer. It also contains code to start a new game or exit the game.
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 ratings0% found this document useful (0 votes)
117 views1 page
Exercise 14
This document contains code for a rock-paper-scissors game. It defines constants for rock, paper, and scissors and generates a random computer throw. When the user selects rock, paper, or scissors by clicking a button, it compares the selection to the computer's throw and displays the result - whether it's a draw, a win for the user, or a win for the computer. It also contains code to start a new game or exit the game.
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 'Jacob Schantli 4/26/2016
Const ROCK As Integer = 1
Const PAPER As Integer = 2 Const SCISSORS As Integer = 3 Dim computerThrow As Integer Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click Randomize() computerThrow = Int(3 * Rnd() + 1) If Me.radrock.Checked And computerThrow = ROCK Then Me.lblWinner.Text = "Computer throws Rock. It's a Draw!" ElseIf Me.radrock.Checked And computerThrow = PAPER Then Me.lblWinner.Text = "Computer throws Paper. Computer wins!" ElseIf Me.radscissors.Checked And computerThrow = SCISSORS Then Me.lblWinner.Text = "Computer throws Scissors. You win!" End If If Me.radpaper.Checked And computerThrow = ROCK Then Me.lblWinner.Text = "Computer throws Rock. You win!" ElseIf Me.radpaper.Checked And computerThrow = PAPER Then Me.lblWinner.Text = "Computer throws Paper. It's a Draw!" ElseIf Me.radpaper.Checked And computerThrow = SCISSORS Then Me.lblWinner.Text = "Computer throws Scissors. Computer wins!" End If If Me.radscissors.Checked And computerThrow = ROCK Then Me.lblWinner.Text = "Computer throws Rock. Computer wins!" ElseIf radscissors.Checked And computerThrow = PAPER Then Me.lblWinner.Text = "Computer throws Paper. You win!" ElseIf Me.radscissors.Checked And computerThrow = SCISSORS Then Me.lblWinner.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 lblWinner.Text = "" radpaper.Checked = False radrock.Checked = False radscissors.Checked = False End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Close() End Sub End Class