Hello,
I am very very new at VB 2008 and Coding. I need to create a Basketball simulator that has two teams of five players each. Each player has an offensive, defensive and shooting percentage. whih are randomly generated and the uses can randomly generate them until he is happy with the team. I was able to code this part.
However, this is the part I'm having difficulty with . The player then press a simulate butoon which will trigger match-up between the two teams in this manner one team is defense and the other is offense . The defensive rank of the defensive plyer is compared to the offensive rank of the offensive player. If the offensive rank is higher then the offensive player gets to shoot. A random number from 1 - 100 is generated if this is below the scoring percentage of the offensive player that team scores 2 points. Each match up last 24 second there are 4 quarters 12 minutes long total of 120 march up. My problem is I cannot figure out how to display the randks shooting percetage and attempts per quarter in the score holders. Please someone , please help. Thank you so much for taking time to review this. Here are my codes so far
Option Explicit On
Option Strict On
Public Class mainForm
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
totalScoreBoard.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles homeButton.Click
Dim number As Integer
Dim randomGenerator As New Random
number = randomGenerator.Next((8), 11)
TextBox1.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox2.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox3.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox4.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox5.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox6.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox7.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox8.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox9.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox10.Text = Convert.ToString(number)
'generate and display radom number 55 - 80
number = randomGenerator.Next(55, 81)
TextBox11.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox12.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox13.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox14.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox15.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles visitorButton.Click
Dim number As Integer
Dim randomGenerator As New Random
number = randomGenerator.Next((8), 11)
TextBox90.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox89.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox88.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox87.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox151.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox86.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox85.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox84.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox83.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox82.Text = Convert.ToString(number)
number = randomGenerator.Next((8), 11)
TextBox81.Text = Convert.ToString(number)
'generate and display radom number 55 - 80
number = randomGenerator.Next(55, 81)
TextBox80.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox79.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox78.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox77.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
TextBox76.Text = Convert.ToString(number)
number = randomGenerator.Next(55, 81)
End Sub
Private Sub playButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles playButton.Click
Dim homeOffRank(4) As Integer
Dim HomeDefRank(4) As Integer
Dim VisitorOffRank(4) As Integer
Dim VisitorDefRank(4) As Integer
Dim player As Integer
Dim HomeShotRank(4) As Integer
Dim VisitorShotRank(4) As Integer
Dim RandomGenerator As New Random
Dim isConverted As Boolean
Dim I As Integer = 0
'generate random player from Home and Visitor
player = RandomGenerator.Next(1, 11)
Label84.Text = CStr(RandomGenerator.Next(1, 101))
Dim offense As Integer
Dim randomgenerator2 As New Random
offense = randomgenerator2.Next(0, 2)
If offense = 0 Then Label1.Text = "Home Team Offense"
If offense = 0 Then Label2.Text = "Visitor Team Defense"
If offense = 1 Then Label1.Text = "Home Team Defense"
If offense = 1 Then Label2.Text = "Visitor Team Offense"
'compare the offensive rank of the offensive player to the defensive
'rank of the defensive player.
Dim HomeTeam(4) As Boolean
Dim VisitorTeam(4) As Boolean
Dim HomeTeamOff As Boolean
Dim VisitorTeamOff As Boolean
If Label1.Text = "Offense" Then
HomeTeamOff = True
ElseIf Label1.Text = "Defense" Then
VisitorTeamOff = True
End If
If HomeTeamOff = True AndAlso Label1.Text = "Home Player #1" Then
HomeTeam(0) = True
ElseIf HomeTeamOff = True AndAlso Label1.Text = "Home Player #2" Then
HomeTeam(1) = True
ElseIf HomeTeamOff = True AndAlso Label1.Text = "Home Player #3" Then
HomeTeam(2) = True
ElseIf HomeTeamOff = True AndAlso Label1.Text = "Home Player #4" Then
HomeTeam(3) = True
ElseIf HomeTeamOff = True AndAlso Label1.Text = "Home Player #5" Then
HomeTeam(4) = True
End If
If VisitorTeamOff = True AndAlso Label2.Text = "Visitor Player #1" Then
VisitorTeam(0) = True
ElseIf VisitorTeamOff = True AndAlso Label2.Text = "Visitor Player #2" Then
VisitorTeam(1) = True
ElseIf VisitorTeamOff = True AndAlso Label2.Text = "Visitor Player #3" Then
VisitorTeam(2) = True
ElseIf VisitorTeamOff = True AndAlso Label2.Text = "Visitor Player #4" Then
VisitorTeam(3) = True
ElseIf VisitorTeamOff = True AndAlso Label2.Text = "Visitor Player #5" Then
VisitorTeam(4) = True
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gameTimer.Tick
gameTimer.Enabled = True
End Sub
Private Sub Panel3_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
End Sub
Private Sub TextBox39_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox40_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Label21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Label22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox44_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox43_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox42_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox41_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox45_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Label84_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label84.Click
End Sub
Private Sub exitButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton1.Click
Me.Close()
End Sub
End Class