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.
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.
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.
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
Imports Imports Partial Class Inherits Dim As New Dim As New Dim As New Dim As String Dim As Boolean Dim As New Protected Sub Byval As Object Byval As Handles Me If Not Then