I am trying to write a program that will keep track of players' victory.
Everything works except someone can tell me why my if
statement is not working?
A clear choice on the public class on form 1 private player 1 string string as personal player2 string in private player1Wins integer private player2Wins as integer as in the form of personal tie integer personal sub btnExit_Click (as this object, e EventArgs) as handle btnExit.Click Me.Close () End sub Private sub frmMainForm_Load (as this object, EventArgs e) MyBase.Load Player1 = InputBox ( "Player Enter the name of 1: ") lblPlayer1.Text = (Player 1 +" score of: ") Player2 = Input box ("Enter the name of Player 2:") lblplayer2.Text = (Player2 + "score:") End sub personal sub btnRoll_Click (as the object, in the form of e EventArgs) handle btnRoll.Click "rolling the dice dim randGen New random dim intNum1 integer dim intNum2 integer dim intNum3 integer dim intNum4 as as as as the game integer Er 'random integer as dim Inteltebl 2 Intig integer as dim Intotl 1 to 6 intNum1 = randGen Next (1, 7) intNum2 = randGen Next (1, 7) intNum3 = randGen Next (1, 7) intNum4 = randGen.Next (1, 7) Select to display the correct image PicDie1 case intNum1 case 1 picDie1.Image = picOneDot.Image Episode 2 picDie1.Image = picTwoDots.Image Episode 3 picDie1.Image = picThreeDots .Image Episode 4 picDie1.Image = picFourDots.Image Episode 5 picDie1.Image = PicFiveDots.Image Episode 6 picDie1.Image = picSixDots.Image choose to display the correct image case end select 'picDie2 intNum2 case 1 picDie2.Image = picOneDot .image case 2 picDie2.Image = picTwoDots.Image Case 3 picDie2.Image = picThreeDots. Image Case 4 picDie2.Image = picFourDots.Image Episode 5 picDie2.Image = picFiveDots.Image Episode 6 picDie2.Image = picSixDots.Image Choose Ending 'picDie3 Case selection in the right image intNum3 case 1 picDie3.Image = picOneDot.Image Case 2 picDie3 .image = picTwoDots.Image Case 3 picDie3.Image = picThreeDots.Image Case 4 Display PicDie3.Image = picFourDots.Image Episode 5 picDie3.Image = picFiveDots.Image Case 6 picDie3.Image = picSixDots.Image Choose the right image in picDie4 Display Case Select intNum4 Case 1 picDie4.Image = picOneDot.Image Case 2 picDie4. Image = picTwoDots.Image Case 3 picDie4.Image = picThreeDots.Image Episode 4 picDie4.Image = picFourDots.Image Episode 5 picDie4.Image = picFiveDots.Image Case 6 picDie4.Image = picSixDots.Image end choose to calculate the total number display Points to be intTotal = intNum1 + intNum2 lblTotal.Text = intTotal.ToString () intTotal2 = intNum3 + intNum4 lblTotal2.Text = intTotal2.ToString () if Player 1 & gt; Player 2 then message box. Show ("Player wins 1") lblWins.Text = CST (Player 1 Vince) Player 1 Vince = Player 1 Vince + 1 Player 2 & gt; Player1 Then MessageBox.Show ( "Player2Wins") lblWins2.Text = CSTR (Player2Wins) Player2Wins = Player2Wins +1 Else: MessageBox.Show ( "TIE") lblTies.Text = CSTR (tie) tie tie = +1 end if End Sub
You are comparing two players' NAMES instead of prices and comparison for If the second player should be one for the first, if
'is calculated and displayed the total number of dots intTotal = intNum1 + intNum2 lblTotal.Text = intTotal.ToString () intTotal2 = intNum3 + IntNum4 lblTotal2. Text = intTotal2.ToString () if Intralt & gt; IntTotal2 then message box. Show ("Player1 wins") Player1Wins = Player1Wins + 1lblWins.Text = CStr (Player1Wins) Otherwise if intTotal2 & gt; IntTotal1 then MessageBox.Show ("Player2Wins") Player2Wins = Player2Wins + 1 lblWins2.Text = CSTR (Player2Wins) or otherwise MessageBox.Show ("tie") tie = tie + 1lblTies.Text = CSTR (tie) end then
and label updates must be after the counter increase for win and relationship
No comments:
Post a Comment