Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- 'Sets the Variables to Integers
- Dim pcard1 As Integer
- Dim pcard2 As Integer
- Dim pcard3 As Integer
- Dim pcard4 As Integer
- Dim dcard1 As Integer
- Dim dcard2 As Integer
- Dim dcard3 As Integer
- Dim dcard4 As Integer
- Dim counter As Integer
- Dim dcounter As Integer
- Dim total As Integer
- Dim dtotal As Integer
- 'New Game Button
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- 'Generates a two new cards for the Player
- Randomize() 'This makes it so the Randomizer isn't always 10, 7, 4
- pcard1 = Int(Rnd() * 13) + 1
- pcard2 = Int(Rnd() * 13) + 1
- lblpcard1.Text = pcard1
- lblpcard2.Text = pcard2
- 'Generates a two new cards for the Dealer
- dcard1 = Int(Rnd() * 13) + 1
- dcard2 = Int(Rnd() * 13) + 1
- lbldcard1.Text = dcard1
- lbldcard2.Text = dcard2
- 'Sets the Value of 11,12,13 to 10 and checks set's the 1 to 11
- If pcard1 > 10 Then
- pcard1 = 10
- End If
- If pcard2 > 10 Then
- pcard2 = 10
- End If
- If pcard1 = 1 Then
- pcard1 = 11
- End If
- If pcard2 = 1 Then
- pcard2 = 11
- End If
- 'Sets the Dealers Value of 11,12,13 to 10 and checks set's the 1 to 11
- If dcard1 > 10 Then
- dcard1 = 10
- End If
- If dcard2 > 10 Then
- dcard2 = 10
- End If
- If dcard1 = 1 Then
- dcard1 = 11
- End If
- If dcard2 = 1 Then
- dcard2 = 11
- End If
- 'Sets Everything But Dealer + Player Cards to Default/Blank
- lblpcard3.Text = "Card 3"
- pcard3 = 0
- pcard4 = 0
- total = 0
- dcard3 = 0
- dcard4 = 0
- lbldcard3.Text = "Card 3"
- dtotal = 0
- counter = 0
- dcounter = 0
- lbllog.Text = "Log:"
- 'Calculates the Total and Checks to see if It's a BlackJack
- total = pcard1 + pcard2
- dtotal = dcard1 + dcard2
- If total = 21 Then
- lbllog.Text = "Black Jack!" & total
- End If
- End Sub
- 'Hit Button
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If counter = 1 Then
- lbllog.Text = "Second Hit" & total
- counter = counter + 1
- ElseIf counter = 2 Then
- lbllog.Text = "Third Hit" & total
- counter = counter + 1
- ElseIf counter = 3 Then
- lbllog.Text = "Fourth Hit" & total
- Else
- 'On the First Hit, Generates a the Third Player Card
- counter = counter + 1
- pcard3 = Int(Rnd() * 13) + 1
- lblpcard3.Text = pcard3
- 'Checks if the card is over 11 then set it to a value of 10
- If pcard3 > 10 Then
- pcard3 = 10
- End If
- 'Calculates Current Total
- total = total + pcard3
- 'Checks the Aces then Recalculates the Total
- If total > 21 Then
- If pcard1 = 11 Then
- pcard1 = 1
- total = total - 10
- ElseIf pcard2 = 11 Then
- pcard2 = 1
- total = total - 10
- ElseIf pcard3 = 11 Then
- pcard3 = 1
- total = total - 10
- End If
- End If
- 'Checks to see if the Player Busted
- lbllog.Text = "First Hit" & total
- If total > 21 Then
- lbllog.Text = "Busted" & total
- End If
- End If
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- total = pcard1 + pcard2 + pcard3 + pcard4
- 'Starts Dealing the dealers cards. While the dealer is Equal to or Under 16 he will Hit
- While dtotal <= 16
- If dcounter = 0 Then
- dcard3 = Int(Rnd() * 13) + 1
- lbldcard3.Text = dcard3
- 'Checks to see if the card is over 10 and if it is sets its value to 10.
- If dcard3 > 10 Then
- dcard3 = 10
- End If
- dtotal = dtotal + dcard3
- 'Checks the Aces then Recalculates the Total
- If dtotal > 21 Then
- If dcard1 = 11 Then
- dcard1 = 1
- total = total - 10
- ElseIf dcard2 = 11 Then
- dcard2 = 1
- total = total - 10
- ElseIf dcard3 = 11 Then
- dcard3 = 1
- total = total - 10
- End If
- 'Ends te Counter and starts the next Hit.
- ElseIf dcounter = 1 Then
- dcard4 = Int(Rnd() * 13) + 1
- lbldcard4.Text = dcard4
- dtotal = dtotal + dcard4
- ElseIf dcounter = 2 Then
- ElseIf dcounter = 3 Then
- End If
- End If
- End While
- lbllog.Text = total & dtotal
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- End Sub
- End Class
Add Comment
Please, Sign In to add comment