
-----------------------------------
bao_luk
Thu May 15, 2008 8:56 pm

Help with 21 card game
-----------------------------------
Here is the question:
          Create a Game 21 application to simulate a simplified version of the game '21'. A deck of cards numbered 1 through 10 is used and any number can be repeated. The computer starts by dealing you (the user) two randomly picked cards, and deals itself three randomly picked cards that are not revealed until the Check Scores button is clicked. You may then draw as many cards as you want, one by one. If both scores are over 21, or if both are equal but under 21, the game is declared a draw. Otherwise, the winner is the one with highest score less than or equal to 21. If one score is over 21 and the other is 21 or less, the player with 21 or less is declared the winner. The result should be displayed in a message box. 

So what I did is this:

Option Explicit

Private intPlayer As Integer
Private intComputer As Integer

Private Sub Form_Load()
Randomize
lblPlayerDealt.Caption = Int(10 * Rnd + 1)
lblPlayerDealt2.Caption = Int(10 * Rnd + 1)
End Sub

Private Sub cmdDraw_Click()   21 Or intPlayer = intComputer Then
    MsgBox "That's a draw."
ElseIf intPlayer = 21 Or intPlayer > intComputer And intPlayer < 21 Then
    MsgBox "Player wins."
ElseIf intComputer = 21 Or intComputer > intPlayer And intComputer < 21 Then
    MsgBox "Computer wins."
ElseIf intPlayer > 21 And intComputer < 21 Then
    MsgBox "Computer wins."
ElseIf intPlayer < 21 And intComputer > 21 Then
    MsgBox "Player wins."
Else
End If

End Sub

Private Sub cmdPlay_Click()  