Fix a crash until cause is found, slightly change position of UI element

remotes/origin/master
CrystalMoogle 2023-07-15 22:22:53 +01:00
parent 626b57c982
commit 0c5c9e115b
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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