Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Yuri D
- 'Play Blackjack with the computer
- Public Class Blackjack
- Dim pcard1 As Integer
- Dim pcard2 As Integer
- Dim pcard3 As Integer
- Dim ccard1 As Integer
- Dim ccard2 As Integer
- Dim ccard3 As Integer
- Dim ptotal As Integer
- Dim ctotal As Integer
- Dim total As Integer
- Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles btnDone.Click
- Close()
- End Sub
- Private Sub btnDraw_Click(sender As System.Object, e As System.EventArgs) Handles btnDraw.Click
- lblplayerdealt1.Visible = True
- lblplayerdealt2.Visible = True
- lblplayerdealt1.Text = CInt(Int((10 * Rnd()) + 1))
- lblplayerdealt2.Text = CInt(Int((10 * Rnd()) + 1))
- lblplayerdrew.Text = CInt(Int((10 * Rnd()) + 1))
- lblcompdealt.Text = CInt(Int((10 * Rnd()) + 1))
- lblcompdealt2.Text = CInt(Int((10 * Rnd()) + 1))
- lblcompdrew.Text = CInt(Int((10 * Rnd()) + 1))
- pcard1 = lblplayerdealt1.Text
- pcard2 = lblplayerdealt2.Text
- pcard3 = lblplayerdrew.Text
- ptotal = pcard1 + pcard2 + pcard3
- ccard1 = lblcompdealt.Text
- ccard2 = lblcompdealt2.Text
- ccard3 = lblcompdrew.Text
- ctotal = ccard1 + ccard2 + ccard3
- End Sub
- Private Sub btnCheck_Click(sender As System.Object, e As System.EventArgs) Handles btnCheck.Click
- lblcompdealt.Visible = True
- lblcompdealt2.Visible = True
- lblcompdrew.Visible = True
- lblplayerdrew.Visible = True
- total = ptotal - ctotal
- 'THIS WORKS DONT CHANGE ME
- If ctotal > 21 And ptotal > 21 Then 'Both Over
- MsgBox("Both over")
- ElseIf ctotal = ptotal Then 'Draw
- MsgBox("Draw")
- ElseIf total < 0 And ctotal >= 21 Or ptotal > 21 And ctotal <= 21 Then 'Computer wins
- MsgBox("Computer wins")
- ElseIf total > 0 And ptotal >= 21 Or ptotal <= 21 And ctotal > 21 Then ' Player wins
- MsgBox("Player Wins")
- ElseIf ctotal > 21 Then
- MsgBox("Player Wins")
- ElseIf ptotal > 21 Then
- MsgBox("Computer Wins")
- ElseIf total > 0 Then
- MsgBox("Player wins")
- ElseIf total < 0 Then
- MsgBox("Computer wins")
- End If
- MsgBox("Player: " & ptotal & " " & "Computer: " & ctotal)
- 'THIS WORKS DONT CHANGE ME
- End Sub
- Private Sub Blackjack_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- Randomize()
- End Sub
- Private Sub btnPlayagain_Click(sender As System.Object, e As System.EventArgs) Handles btnPlayagain.Click
- Application.Restart()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement