Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors
Rock, paper, scissors Rock, paper, scissors
Rock, paper, scissors
Go Back  Xtreme Visual Basic Talk > > > Rock, paper, scissors


Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2013, 12:05 PM
yuuie_mio yuuie_mio is offline
Newcomer
 
Join Date: Mar 2013
Location: Asia
Posts: 1
Default Rock, paper, scissors


Edit by Moderator: Split from this thread

Edit: We have a policy no to reply to threads which are inactive for more than 30 days. Also we encourage you to start a new thread for asking questions. Please also post your questions in the correct forum


Can Someone help me??

1. I have 2 FRAMES
2. In each frame, I have 3 pictures- paper, scissor, and rock
3. I have 2 labels for player1 and player2 score
4. I have 2 command buttons, “Choose” button and “Exit” button

I’m having problems running it. It runs but there are some problems. I tried looking on different forums, sites, that I think would help me but they doesn’t answer my questions to my problem. Please help me. I couldn’t figure out the problem. I would appreciate your help. Please reply asap.
Code:
Private Sub cmd_Choose_Click()

        Dim number As Integer
        Dim CpuScore As Integer
        Dim Totalscore As Integer

        CpuScore = 0
        number = (3 * Rnd())

        If Me.img_Rock1.Enabled And img_Rock2.Enabled Then
            MsgBox "Player 1 threw rock. DRAW!"
            
        ElseIf Me.img_Rock1.Enabled And img_Paper2.Enabled Then
          MsgBox "Player 1 threw Rock. YOU LOSE because paper covers rock."
            CpuScore = CpuScore + 1
            
       ElseIf Me.img_Rock1.Enabled And img_Scissors2.Enabled Then
            MsgBox "Player 1 threw Rock. You WIN because rock breaks scissors."
      
        End If

        If Me.img_Paper1.Enabled And img_Rock2.Enabled Then
            MsgBox "Player 1 threw paper. You WIN! because paper covers rock."
            
       ElseIf Me.img_Paper1.Enabled And img_Paper2.Enabled Then
            MsgBox "Player 1 threw Paper. DRAW!"
            CpuScore = CpuScore + 1
            
        ElseIf Me.img_Paper1.Enabled And img_Scissors2.Enabled Then
            MsgBox "Player 1 threw Paper. You lose because scissors cut paper."
       
        End If



        If Me.img_Scissors1.Enabled And img_Rock2.Enabled Then
            MsgBox "Player 1 threw scissors. You lose because rock breaks scissors"
        
        ElseIf Me.img_Scissors1.Enabled And img_Paper2.Enabled Then
            MsgBox "Player 1 threw scissors. You Win because scissors cut paper."
            CpuScore = CpuScore + 1
          
            
        ElseIf img_Scissors1.Enabled And img_Scissors2.Enabled Then
            MsgBox "Player 1 threw scissors. Draw!"
            
        End If
        
        Totalscore = CpuScore
        Label2.Caption = Val(Label2.Caption) + 1
        Label5.Caption = Val(Label5.Caption) + 1

End Sub

Private Sub img_Paper1_Click()
If img_Paper1.Enabled Then
MsgBox "Paper!"
End If
End Sub

Private Sub img_Paper2_Click()
If img_Paper1.Enabled Then
MsgBox "Paper!"
End If
End Sub

Private Sub img_Rock1_Click()

If img_Rock1.Enabled Then
MsgBox "Rock!"
End If
End Sub

Private Sub img_Rock2_Click()
If img_Rock2.Enabled Then
MsgBox "Rock!"
End If
End Sub

Private Sub img_Scissors1_Click()
If img_Scissors1.Enabled Then
MsgBox "Scissors!"
End If
End Sub

Private Sub img_Scissors2_Click()
If img_Scissors1.Enabled Then
MsgBox "Scissors!"
End If
End Sub

Last edited by Flyguy; 03-02-2013 at 04:32 PM.
Reply With Quote
  #2  
Old 03-03-2013, 03:03 AM
passel's Avatar
passelRock, paper, scissors passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

You should mention what your problems are.
The code is checking the .Enabled property of some things, and by the name I would assume they were Image controls, but your post suggests that they are picture controls( "I have 3 pictures").
I don't see where you set or clear the .Enabled property and the code wouldn't make much sense if you did, since if you cleared (set it to False) the .Enabled property you wouldn't get a Click event i.e.

Private Sub img_Scissors2_Click()
If img_Scissors1.Enabled Then

is "nonsense" since the img_Scissor1 would always have to be Enabled in order to get a Click event.
That is the purpose of the .Enabled property.
If the control is enabled (.Enabled = True), the user can interact with it, and it will generate "input" events like Mouse and Key.
If the control is disabled (.Enabled = False), the user can't interact with it, and it will not generate "input" events from the mouse or keyboard.

I suppose you could make it work by not checking to see if the control is .Enabled in the controls click event (it has to be, or you wouldn't get a click event), but rather disable the other two controls in the set of three (.Enable = False on the other two).
This would solve two problems.
It would allow the player to only be able to choose one item (once the choice is made, the other choices are disabled so can't be selected).
And the "choose" button logic whould have a chance to work because only the selected items would be enabled.
Of course, that assumes both player's selection are made before you hit the choose button, and that your logic in the choose button code is correct.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors Rock, paper, scissors
Rock, paper, scissors
Rock, paper, scissors
 
Rock, paper, scissors
Rock, paper, scissors
 
-->