I'm using Visual Basic 2008 express edition to design a black jack game and I'm trying to figure out how to loop a set of if states for the money won and lost during the game. I've included what I've come up with so far for the statements, but I'm having trouble figuring out how to properly place them in a do loop and what I should associate them with so that the loop will continue running when the deal button, hit buttons and stand button are pressed but the money will reset if the new game button is pressed. I was considering an association with the moneyLabelBox. Any suggestions would help. Thanks.
Code:Dim moneyDefault As Integer Dim moneyAdd As Integer Dim moneySub As Integer Dim moneyBJAdd As Integer Dim moneyDraw As Integer Dim dealerTotal As Integer Dim playerTotal As Integer Integer.TryParse(dealerLabelBox.Text, dealerTotal) Integer.TryParse(playerLabelBox.Text, playerTotal) money amounts moneyDefault = 500 moneyAdd = 10 moneySub = 10 moneyBJAdd = 20 moneyDraw = 5 ' if statements If playerTotal > dealerTotal AndAlso playerTotal < 21 Then moneyDefault = moneyDefault + moneyAdd End If If playerTotal = 21 AndAlso dealerTotal < 22 Then moneyDefault = moneyDefault + moneyBJAdd End If If playerTotal < dealerTotal AndAlso dealerTotal < 22 Then moneyDefault = moneyDefault - moneySub End If If playerTotal = dealerTotal AndAlso playerTotal < 21 Then moneyDefault = moneyDefault + moneyDraw End If ' show money amount moneyLabelBox.Text = moneyDefault.ToString("C2")




Reply With Quote