Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Form Design: https://plus.google.com/b/115806511419535531782/115806511419535531782/posts/GcBWSg2YxRv?pageId=115806511419535531782&hl=en&pid=6205320338051650082&oid=115806511419535531782
- ---------------------------------------------------------------------------------------------------------------------------------
- Public Class Form1
- Dim Input As Integer
- Dim wins As Integer
- Dim loses As Integer
- Dim ties As Integer
- Dim best10 As Integer
- Dim best5 As Integer
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- pbCompPaper.Hide()
- pbCompRock.Hide()
- pbCompScissors.Hide()
- pbScissors.Hide()
- pbPaper.Hide()
- pbRock.Hide()
- Dim r As Rectangle
- If Parent IsNot Nothing Then
- r = Parent.RectangleToScreen(Parent.ClientRectangle)
- Else
- r = Screen.FromPoint(Me.Location).WorkingArea
- End If
- Dim x = r.Left + (r.Width - Me.Width) \ 2
- Dim y = r.Top + (r.Height - Me.Height) \ 2
- Me.Location = New Point(x, y)
- best10 = False
- best5 = False
- End Sub
- Private Sub btnScissors_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScissors.Click
- pbScissors.Show()
- pbPaper.Hide()
- pbRock.Hide()
- Randomize()
- Dim computer As Double
- Input = 3
- computer = Rnd()
- computer = Int(Rnd() * 3) + 1
- If computer <= 3 And computer > 2 And Input = 3 Then
- lblDisply.Text = "It's a tie"
- Me.BackColor = Color.RoyalBlue
- ties = Val(lblTies.Text) + 1
- lblTies.Text = ties
- pbCompPaper.Hide()
- pbCompRock.Hide()
- pbCompScissors.Show()
- ElseIf computer <= 1 And Input = 3 Then
- lblDisply.Text = "Computer chose rock, you lost!"
- Me.BackColor = Color.Red
- loses = Val(lblLoses.Text) + 1
- lblLoses.Text = loses
- pbCompPaper.Hide()
- pbCompRock.Show()
- pbCompScissors.Hide()
- ElseIf computer > 1 And computer <= 2 And Input = 3 Then
- lblDisply.Text = "Computer chose paper, you win!"
- Me.BackColor = Color.Green
- wins = Val(lblWins.Text) + 1
- lblWins.Text = wins
- pbCompPaper.Show()
- pbCompRock.Hide()
- pbCompScissors.Hide()
- End If
- If best10 = True And wins >= 10 Then
- MsgBox("You Won")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best10 = True And loses >= 10 Then
- MsgBox("You Lost")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And wins >= 5 Then
- MsgBox("You Won")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And loses >= 5 Then
- MsgBox("You Lost")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And ties >= 5 Then
- MsgBox("You Tied")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best10 = True And ties >= 10 Then
- MsgBox("You Tied")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- End Sub
- Private Sub btnPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaper.Click
- pbScissors.Hide()
- pbRock.Hide()
- pbPaper.Show()
- Randomize()
- Dim computer As Double
- Input = 2
- computer = Rnd()
- computer = Int(Rnd() * 3) + 1
- If computer <= 2 And computer > 1 And Input = 2 Then
- lblDisply.Text = "It's a tie"
- Me.BackColor = Color.RoyalBlue
- ties = Val(lblTies.Text) + 1
- lblTies.Text = ties
- pbCompPaper.Show()
- pbCompRock.Hide()
- pbCompScissors.Hide()
- ElseIf computer <= 1 And Input = 2 Then
- lblDisply.Text = "Computer chose rock, you win!"
- Me.BackColor = Color.Green
- wins = Val(lblWins.Text) + 1
- lblWins.Text = wins
- pbCompPaper.Hide()
- pbCompRock.Show()
- pbCompScissors.Hide()
- ElseIf computer >= 2 And computer <= 3 And Input = 2 Then
- lblDisply.Text = "Computer chose scissors, you lost"
- Me.BackColor = Color.Red
- loses = Val(lblLoses.Text) + 1
- lblLoses.Text = loses
- pbCompPaper.Hide()
- pbCompRock.Hide()
- pbCompScissors.Show()
- End If
- If best10 = True And wins >= 10 Then
- MsgBox("You Won")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best10 = True And loses >= 10 Then
- MsgBox("You Lost")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And wins >= 5 Then
- MsgBox("You Won")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And loses >= 5 Then
- MsgBox("You Lost")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And ties >= 5 Then
- MsgBox("You Tied")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best10 = True And ties >= 10 Then
- MsgBox("You Tied")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- End Sub
- Private Sub btnRock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRock.Click
- pbPaper.Hide()
- pbScissors.Hide()
- pbRock.Show()
- Randomize()
- Dim computer As Double
- Input = 1
- computer = Rnd()
- computer = Int(Rnd() * 3) + 1
- If computer <= 1 And Input = 1 Then
- lblDisply.Text = "It's a tie"
- Me.BackColor = Color.RoyalBlue
- ties = Val(lblTies.Text) + 1
- lblTies.Text = ties
- pbCompPaper.Hide()
- pbCompRock.Show()
- pbCompScissors.Hide()
- ElseIf computer > 1 And computer <= 2 And Input <= 1 Then
- lblDisply.Text = "Computer chose paper, you lost!"
- Me.BackColor = Color.Red
- loses = Val(lblLoses.Text) + 1
- lblLoses.Text = loses
- pbCompPaper.Show()
- pbCompRock.Hide()
- pbCompScissors.Hide()
- ElseIf computer > 2 And Input = 1 Then
- lblDisply.Text = "Computer chose scissors, you win!"
- Me.BackColor = Color.Green
- wins = Val(lblWins.Text) + 1
- lblWins.Text = wins
- pbCompPaper.Hide()
- pbCompRock.Hide()
- pbCompScissors.Show()
- End If
- If best10 = True And wins >= 10 Then
- MsgBox("You Won")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best10 = True And loses >= 10 Then
- MsgBox("You Lost")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And wins >= 5 Then
- MsgBox("You Won")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And loses >= 5 Then
- MsgBox("You Lost")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best5 = True And ties >= 5 Then
- MsgBox("You Tied")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- If best10 = True And ties >= 10 Then
- MsgBox("You Tied")
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- Button2.PerformClick()
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Application.Exit()
- End Sub
- Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
- Application.Exit()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Application.Restart()
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- End Sub
- Private Sub BestOf10ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BestOf10ToolStripMenuItem.Click
- Me.Text = "RPS (Mode: Best of 10)"
- If best5 = True Then
- best5 = False
- End If
- best10 = True
- End Sub
- Private Sub BestOf5ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BestOf5ToolStripMenuItem.Click
- Me.Text = "RPS (Mode: Best of 5)"
- If best10 = True Then
- best10 = False
- End If
- best5 = True
- End Sub
- Private Sub DefaultToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DefaultToolStripMenuItem.Click
- Button2.PerformClick()
- Me.Text = "RPS (Mode: Default)"
- lblDisply.Text = "Click a button "
- Me.BackColor = Color.RoyalBlue
- Form1_Load(Me, New System.EventArgs)
- lblLoses.Text = "0"
- lblTies.Text = "0"
- lblWins.Text = "0"
- best10 = False
- best5 = False
- End Sub
- Private Sub Button2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.MouseEnter
- With Button2
- .Font = New Font("Impact", 12)
- .Text = "Reloads Form"
- End With
- End Sub
- Private Sub Button2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.MouseLeave
- With Button2
- .Font = New Font("Impact", 20)
- .Text = "Reset"
- End With
- End Sub
- Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
- Button1.Text = "Exit?"
- End Sub
- Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave
- Button1.Text = "Exit"
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement