Alright. I am at a loss of what to do. I need help with Visual Basic stuff.
I can't figure out where I am going wrong with this, I have the basic idea of what to do.
This is what I have. It needs to be counting in text boxes. I have tried what I know and nothing is working. I do have it working to indicate when playerone or two has won and when it comes to a tie but I need it to count all those wins and ties.
Public Class frmHighTotals
Private Sub btnEndNow_Click(sender As Object, e As EventArgs) Handles btnEndNow.Click
'Closes the program
Me.Close()
End Sub
Private Sub frmHighTotals_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub btnClickPlay_Click(sender As Object, e As EventArgs) Handles btnClickPlay.Click
'Randomizes numbers for players
Dim RanNum As Integer
Dim RanNum2 As Integer
Dim RanNum3 As Integer
Dim RanNum4 As Integer
Randomize()
RanNum = Int(Rnd() * 20) + 1
RanNum2 = Int(Rnd() * 20) + 1
RanNum3 = Int(Rnd() * 20) + 1
RanNum4 = Int(Rnd() * 20) + 1
txtP1Num1.Text = RanNum
txtP1Num2.Text = RanNum2
txtP2Num1.Text = RanNum3
txtP2Num2.Text = RanNum4
'Adding Players Numbers for Totals
txtPlay1Total.Text = Val(txtP1Num1.Text) + Val(txtP1Num2.Text)
txtPlay2Total.Text = Val(txtP2Num1.Text) + Val(txtP2Num2.Text)
'Total Wins Per Player
Dim WinPlay1 As Integer
Dim WinPlay2 As Integer
Dim TiePlay As Integer
txtPlay1Wins.Text = WinPlay1
txtPlay2Wins.Text = WinPlay2
txtTies.Text = TiePlay
'Play one wins
If CInt(txtPlay1Total.Text) > CInt(txtPlay2Total.Text) Then
MsgBox(" Player 1 has Won!")
txtPlay1Wins.Text = Int(txtPlay1Wins.Text + txtPlay1Wins.Text) + 1
'Player ties
ElseIf CInt(txtPlay1Total.Text) = CInt(txtPlay2Total.Text) Then
MsgBox("Tie!")
txtTies.Text = Int(txtTies.Text + txtTies.Text) + 1
'Player 2 wins
ElseIf CInt(txtPlay1Total.Text) < CInt(txtPlay2Total.Text) Then
MsgBox(" Player 2 Has Won")
txtPlay2Wins.Text = Int(txtPlay2Wins.Text + txtPlay2Wins.Text) + 1
End If
End Sub
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
'Clears wins and tie boxes for game to reset counter
txtPlay1Wins.Clear()
txtPlay2Wins.Clear()
txtTies.Clear()
End Sub
Private Sub btnNewGame_Click(sender As Object, e As EventArgs) Handles btnNewGame.Click
'Starts New Game and clears fields
Select Case MsgBox("Start a New Game?", MsgBoxStyle.YesNo, "New Game?")
Case MsgBoxResult.Yes
MessageBox.Show("Enter New Names!")
txtOnePName.Clear()
txtP1Num1.Clear()
txtP1Num2.Clear()
txtP2Num1.Clear()
txtP2Num2.Clear()
txtPlay1Total.Clear()
txtPlay1Wins.Clear()
txtPlay2Total.Clear()
txtPlay2Wins.Clear()
txtTies.Clear()
txtTwoPName.Clear()
'Does not start new game, closes diaglog box
Case MsgBoxResult.No
MessageBox.Show("Okay!")
End Select
End Sub