diff --git a/BlackjackGUI/Form1.Designer.vb b/BlackjackGUI/Form1.Designer.vb index c253328..f416f41 100644 --- a/BlackjackGUI/Form1.Designer.vb +++ b/BlackjackGUI/Form1.Designer.vb @@ -225,7 +225,7 @@ Partial Class Form1 ' WinMessage.AutoSize = True WinMessage.Font = New Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point) - WinMessage.Location = New Point(565, 221) + WinMessage.Location = New Point(535, 216) WinMessage.Name = "WinMessage" WinMessage.Size = New Size(0, 30) WinMessage.TabIndex = 15 diff --git a/BlackjackGUI/Form1.vb b/BlackjackGUI/Form1.vb index ab4b505..6f917b4 100644 --- a/BlackjackGUI/Form1.vb +++ b/BlackjackGUI/Form1.vb @@ -73,7 +73,14 @@ deck.RemoveAt(0) GetTotal(player) Dim cardNumber As String = If(isDealer, (player.hand.count + 5).ToString(), player.hand.count) - Dim pictureBox As PictureBox = CType(Me.Controls.Find("PlayerCard" + cardNumber, True).First(), PictureBox) + Dim pictureBox As PictureBox + Try + pictureBox = CType(Me.Controls.Find("PlayerCard" + cardNumber, True).First(), PictureBox) + Catch ex As Exception + WinMessage.Text = "Error: " + ex.Message + EndGame() + End Try + pictureBox.Image = GetCardImage(card) SetTotalLabels() End Sub @@ -151,10 +158,12 @@ End Sub Sub CheckGame() WinMessage.Text = GetResults() + EndGame() + End Sub + Sub EndGame() HitButton.Enabled = False StandButton.Enabled = False StartGame.Enabled = True - End Sub Function GetResults() If dealer.winType = WinCondition.Blackjack Then