|
-
Feb 2nd, 2015, 07:36 AM
#1
Thread Starter
New Member
Rock Paper Scissors Problem
For some reason Rock ( button1 ) and paper ( button2 ) only display "You Win" and "Its a Draw" However scissors ( button3 ) Displays All 3 "You win", "You Lose" and "Its A Draw, I hope someone can help me find a solution ~David
Public Class Form1
Dim counter As Integer
Dim rock As Integer = 1
Dim paper As Integer = 2
Dim scissors As Integer = 3
Dim userValue As Integer
'rock beats scissors-paper beats rock-scissors beats paper
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
counter = 1
If counter = 1 Then
userValue = rock
End If
Randomize()
Dim computerValue As Integer = CInt(Int((3 * Rnd()) + 1))
If userValue = computerValue Then
Label1.Text = "Its a Draw"
ElseIf userValue = 1 And computerValue = 3 Then
Label1.Text = "You Win"
ElseIf computerValue = 3 And userValue = 1 Then
Label1.Text = "You lose"
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
counter = 2
If counter = 2 Then
userValue = paper
End If
Randomize()
Dim computerValue As Integer = CInt(Int((3 * Rnd()) + 1))
If userValue = computerValue Then
Label1.Text = "Its a Draw"
ElseIf userValue = 2 And computerValue = 1 Then
Label1.Text = "You Win"
ElseIf computerValue = 2 And userValue = 1 Then
Label1.Text = "You lose"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
counter = 3
If counter = 3 Then
userValue = scissors
End If
Randomize()
Dim computerValue As Integer = CInt(Int((3 * Rnd()) + 1))
If userValue = computerValue Then
Label1.Text = "Its a Draw"
ElseIf userValue = 3 And computerValue = 2 Then
Label1.Text = "You Win"
ElseIf computerValue = 1 And userValue = 3 Then
Label1.Text = "You lose"
End If
End Sub
End Class
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|