Private Sub CalcCpoints()
If intCcards = 2 Then
intCpoints = intValues(1) + intValues(3) 'The dealer`s score is the value of the first card (1) and the second card (3)
If intCpoints = 21 Then lblCpoints.Caption = "BlackJack!!!"
If intCpoints = 22 Then intCpoints = 12 'If the dealer gets two aces the score is 12 (or 2...)
If intCpoints <> 21 Then lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCcards = 3 Then
intCpoints = intValues(1) + intValues(3) 'the first two cards...
intCpoints = intCpoints + intValues(intCcards + 2) '... plus the third card
If intCpoints > 21 And intValues(intCcards + 2) = 11 Then 'If the score is higher then 21 and the third card is an ace...
intValues(intCcards + 2) = 1 '...the ace has to be counted as 1 point
Call CalcCpoints 're-calculate the points
End If
If intCpoints > 21 And intValues(3) = 11 Then
intValues(3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(1) = 11 Then
intValues(1) = 1
Call CalcCpoints
End If
If intCpoints <= 21 Then
lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCpoints > 21 Then
lblCpoints.ForeColor = vbRed
lblCpoints.Caption = "Busted! " & intCpoints & " points"
End If
ElseIf intCcards = 4 Then
intCpoints = intValues(1) + intValues(3)
intCpoints = intCpoints + intValues(intCcards + 2)
intCpoints = intCpoints + intValues(intCcards + 3)
If intCpoints > 21 And intValues(intCcards + 3) = 11 Then
intValues(intCcards + 3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(intCcards + 2) = 11 Then
intValues(intCcards + 2) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(3) = 11 Then
intValues(3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(1) = 11 Then
intValues(1) = 1
Call CalcCpoints
End If
If intCpoints <= 21 Then
lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCpoints > 21 Then
lblCpoints.ForeColor = vbRed
lblCpoints.Caption = "Busted! " & intCpoints & " points"
End If
ElseIf intCcards = 5 Then
intCpoints = intValues(1) + intValues(3)
intCpoints = intCpoints + intValues(intCcards + 2)
intCpoints = intCpoints + intValues(intCcards + 3)
intCpoints = intCpoints + intValues(intCcards + 4)
If intCpoints > 21 And intValues(intCcards + 4) = 11 Then
intValues(intCcards + 4) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(intCcards + 3) = 11 Then
intValues(intCcards + 3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(intCcards + 2) = 11 Then
intValues(intCcards + 2) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(3) = 11 Then
intValues(3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(1) = 11 Then
intValues(1) = 1
Call CalcCpoints
End If
If intCpoints <= 21 Then
lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCpoints > 21 Then
lblCpoints.ForeColor = vbRed
lblCpoints.Caption = "Busted! " & intCpoints & " points"
End If
End If
End Sub