Dim playerCount As Integer = 0 Dim playerAce As Integer = 0 Dim dealerCount As Integer = 0 Dim dealerAce As Integer = 0 Dim ipcard, idcard As Integer
Private Sub delay(ByVal dt As Integer) Dim t As Integer t = My.Computer.Clock.TickCount Do If My.Computer.Clock.TickCount >= t + dt Then Exit Do Loop End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Visible = False Label1.Text=”” Label2.Text=”” Label1.Refresh() Label2.Refresh() MyBase.CreateGraphics.Clear(Color.DarkGreen) dealerAce = 0 playerAce = 0 dealerCount = 0 playerCount = 0
cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200, 200, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0)
playerCount += Deck(TopCard).count
If Deck(TopCard).face = 0 Then playerCount += 10 : playerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label2.Text = playerCount.ToString Label2.Refresh() delay(1000)
cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200, 10, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0)
dealerCount += Deck(TopCard).count
If Deck(TopCard).face = 0 Then dealerCount += 10 : dealerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label1.Text = dealerCount.ToString Label1.Refresh() delay(1000)
cdtDrawExt(MyBase.CreateGraphics.GetHdc, 220, 200, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0)
playerCount += Deck(TopCard).count
If Deck(TopCard).face = 0 And playerAce = 0 Then playerCount += 10 : playerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label2.Text = playerCount.ToString Label2.Refresh() delay(1000)
cdtDrawExt(MyBase.CreateGraphics.GetHdc, 220, 10, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0)
dealerCount += Deck(TopCard).count
If Deck(TopCard).face = 0 And dealerAce = 0 Then dealerCount += 10 : dealerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") Label1.Text = dealerCount.ToString Label1.Refresh() delay(1000) ipcard = 2 idcard = 2 Button2.Visible = True Button3.Visible = True End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200 + 20 * ipcard, 200, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0)
playerCount += Deck(TopCard).count
If Deck(TopCard).face = 0 Then playerCount += 10 : playerAce += 1 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") ipcard += 1 Label2.Text = playerCount.ToString Label2.Refresh()
If playerCount > 21 Then If playerAce >= 1 Then playerCount -= 10 playerAce -= 1 Label2.Text = playerCount.ToString Label2.Refresh() Else MsgBox("Player loss!") Button1.Visible = True Button2.Visible = False Button3.Visible = False End If End If End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Button2.Visible = False Button3.Visible = False dealerPlay() End Sub
Private Sub dealerPlay() Do If dealerCount < 17 Then cdtDrawExt(MyBase.CreateGraphics.GetHdc, 200 + 20 * idcard, 10, 75, 100, (Deck(TopCard).face * 4 + Deck(TopCard).suit), 0, 0) dealerCount += Deck(TopCard).count If dealerCount > 21 And dealerAce = 1 Then dealerCount -= 10 : dealerAce -= 1 If Deck(TopCard).face = 0 And dealerCount <= 11 Then dealerCount += 10 TopCard += 1 If TopCard >= 52 Then Shuffle() : MsgBox("NEW DECK!") idcard += 1 Else Exit Do End If Loop
Label1.Text = dealerCount.ToString Label1.Refresh() If dealerCount <= 21 Then If playerCount > dealerCount Then MsgBox("Player win!") Else MsgBox("Dealer win!") End If Else MsgBox("Player win!") End If
Button1.Visible = True Button2.Visible = False Button3.Visible = False
End Sub |