If anyone can help me with this blackjack program it would be greatly appreciated. I'm having trouble making the message box show, and if there are any other errors please tell me how to fix them :(
Option Explicit
Private intcomp, intplayer, intplayer2, intcounter As Integer
Private Sub cmddone_Click()
Unload frm9
End Sub
Private Sub cmddraw_Click()
intcounter = intcounter + 1
If intcounter = 1 Then
lblcard6 = (Int((10 - 1 + 1) * Rnd + 1))
End If
If intcounter = 2 Then
lblcard7 = (Int((10 - 1 + 1) * Rnd + 1))
End If
If intcounter = 3 Then
lblcard8 = (Int((10 - 1 + 1) * Rnd + 1))
End If
If intcounter = 4 Then
lblcard9 = (Int((10 - 1 + 1) * Rnd + 1))
End If
End Sub
Private Sub cmdscore_Click()
lblcard3.Visible = True
lblcard4.Visible = True
lblcard5.Visible = True
intcomp = lblcard3 + lblcard4 + lblcard5
intplayer = lblcard + lblcard2
If intcounter = 0 Then
intplayer = lblcard + lblcard2
If intcomp = intplayer Then
MsgBox "You tie"
ElseIf intcomp > intplayer And intcomp < 22 Then
MsgBox "You lose"
ElseIf intplayer > intcomp And intplayer < 22 Then
MsgBox "You win."
End If
End If
If intcounter = 1 Then
intplayer2 = intplayer + lblcard6
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
If intcounter = 2 Then
intplayer2 = intplayer + lblcard6 + lblcard7
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
If intcounter = 3 Then
intplayer2 = intplayer + lblcard6 + lblcard7 + lblcard8
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
If intcounter = 4 Then
intplayer2 = intplayer + lblcard6 + lblcard7 + lblcard8 + lblcard9
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
End Sub
Private Sub Form_Load()
Randomize
lblcard = (Int((10 - 1 + 1) * Rnd + 1))
lblcard2 = (Int((10 - 1 + 1) * Rnd + 1))
lblcard3 = (Int((10 - 1 + 1) * Rnd + 1))
lblcard4 = (Int((10 - 1 + 1) * Rnd + 1))
lblcard5 = (Int((10 - 1 + 1) * Rnd + 1))
intcounter = 0
lblcard3.Visible = False
lblcard4.Visible = False
lblcard5.Visible = False
End Sub
Option Explicit
Private intcomp, intplayer, intplayer2, intcounter As Integer
Private Sub cmddone_Click()
Unload frm9
End Sub
Private Sub cmddraw_Click()
intcounter = intcounter + 1
If intcounter = 1 Then
lblcard6 = (Int((10 - 1 + 1) * Rnd + 1))
End If
If intcounter = 2 Then
lblcard7 = (Int((10 - 1 + 1) * Rnd + 1))
End If
If intcounter = 3 Then
lblcard8 = (Int((10 - 1 + 1) * Rnd + 1))
End If
If intcounter = 4 Then
lblcard9 = (Int((10 - 1 + 1) * Rnd + 1))
End If
End Sub
Private Sub cmdscore_Click()
lblcard3.Visible = True
lblcard4.Visible = True
lblcard5.Visible = True
intcomp = lblcard3 + lblcard4 + lblcard5
intplayer = lblcard + lblcard2
If intcounter = 0 Then
intplayer = lblcard + lblcard2
If intcomp = intplayer Then
MsgBox "You tie"
ElseIf intcomp > intplayer And intcomp < 22 Then
MsgBox "You lose"
ElseIf intplayer > intcomp And intplayer < 22 Then
MsgBox "You win."
End If
End If
If intcounter = 1 Then
intplayer2 = intplayer + lblcard6
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
If intcounter = 2 Then
intplayer2 = intplayer + lblcard6 + lblcard7
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
If intcounter = 3 Then
intplayer2 = intplayer + lblcard6 + lblcard7 + lblcard8
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
If intcounter = 4 Then
intplayer2 = intplayer + lblcard6 + lblcard7 + lblcard8 + lblcard9
End If
If intcomp > intplayer2 And intcomp < 2 Then
MsgBox "You lose."
ElseIf intplayer2 = intcomp Then
MsgBox "You tie."
ElseIf intplayer2 > intcomp And intplayer2 < 22 Then
MsgBox "You win."
End If
End Sub
Private Sub Form_Load()
Randomize
lblcard = (Int((10 - 1 + 1) * Rnd + 1))
lblcard2 = (Int((10 - 1 + 1) * Rnd + 1))
lblcard3 = (Int((10 - 1 + 1) * Rnd + 1))
lblcard4 = (Int((10 - 1 + 1) * Rnd + 1))
lblcard5 = (Int((10 - 1 + 1) * Rnd + 1))
intcounter = 0
lblcard3.Visible = False
lblcard4.Visible = False
lblcard5.Visible = False
End Sub