Tuesday, March 20, 2012
Rock Paper Scissors - using nested If then else
This really got me confused. The correct format is:
If Me.radRock.Checked And computerChoice = rock Then
Me.lblMessage.Text = "Computer throws rock. It's a draw! Cordial handshake."
Else
If Me.radPaper.Checked And computerChoice = rock Then
Me.lblMessage.Text = "Computer throws rock. You win! Computer sniffles."
Else
If Me.radScissors.Checked And computerChoice = rock Then
Me.lblMessage.Text = "Computer throws rock. Computer wins! Computer dances happily."
End If
End If
End If
I initially did not have the computerChoice defined on every line so it didn't work. Also, just using Else (without an If statement) would not work.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment