VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Rock Paper Sissors Game!.

by pinchbeck (1 Submission)
Category: Games
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 18th October 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Rock Paper Sissors Game!.

API Declarations


'2 text boxs
'3 command buttons


' These are only the required objects, the other captions can be added later.

Rate Rock Paper Sissors Game!.







Private Sub Command1_Click()
Label1.Caption = ""
Label2.Caption = ""
lblwin.Caption = ""

'Random Computer outcomes

Text1.Text = "Rock"
Select Case (1 + Int(Rnd() * 3))
    Case 1
        Text2.Text = "Rock"
    Case 2
        Text2.Text = "Paper"
    Case 3
        Text2.Text = "Sissors"
End Select
'winners for the rock

If Text1.Text = "Rock" And Text2.Text = "Paper" Then
lblwin.Caption = "Paper Covers Rock"
Label2.Caption = "X"
End If

If Text1.Text = "Rock" And Text2.Text = "Sissors" Then
lblwin.Caption = "Rock Smashes Sissors"
Label1.Caption = "X"
End If

If Text1.Text = "Rock" And Text2.Text = "Rock" Then
lblwin.Caption = "Tie"
Label1.Caption = ""
Label2.Caption = ""
End If

End Sub

Private Sub Command2_Click()

Label1.Caption = ""
Label2.Caption = ""
lblwin.Caption = ""

'random computer outcomes

Text1.Text = "Paper"
Select Case (1 + Int(Rnd() * 3))
    Case 1
        Text2.Text = "Rock"
    Case 2
        Text2.Text = "Paper"
    Case 3
        Text2.Text = "Sissors"
End Select

'Winners for paper

If Text1.Text = "Paper" And Text2.Text = "Rock" Then
lblwin.Caption = "Paper Covers Rock"
Label1.Caption = "X"
End If

If Text1.Text = "Paper" And Text2.Text = "Paper" Then
lblwin.Caption = "Tie"
Label1.Caption = ""
Label1.Caption = ""
End If

If Text1.Text = "Paper" And Text2.Text = "Sissors" Then
lblwin.Caption = "Sissors Cut Paper"
Label2.Caption = "X"
End If

End Sub

Private Sub Command3_Click()

Label1.Caption = ""
Label2.Caption = ""
lblwin.Caption = ""

'Random computer outcomes for the sissors button

Text1.Text = "Sissors"
Select Case (1 + Int(Rnd() * 3))
    Case 1
        Text2.Text = "Rock"
    Case 2
        Text2.Text = "Paper"
    Case 3
        Text2.Text = "Sissors"
End Select

'the winners for sissors

If Text1.Text = "Sissors" And Text2.Text = "Rock" Then
lblwin.Caption = "Rock Smashes Sissors"
Label2.Caption = "X"
End If

If Text1.Text = "Sissors" And Text2.Text = "Paper" Then
lblwin.Caption = "Sissors cut Paper"
Label1.Caption = "X"
End If

If Text1.Text = "Sissors" And Text2.Text = "Sissors" Then
lblwin.Caption = "Tie"
Label1.Caption = ""
Label2.Caption = ""
End If
End Sub



Download this snippet    Add to My Saved Code

Rock Paper Sissors Game!. Comments

No comments have been posted about Rock Paper Sissors Game!.. Why not be the first to post a comment about Rock Paper Sissors Game!..

Post your comment

Subject:
Message:
0/1000 characters