Hello all. I'm creating a basketball program. There are two teams of five players each. Each player has a randomly generated offensive and defensive stat. The program randomly picks two players to match up. If the offensive stat of the offensive player is greater than the defensive stat of the defensive player, the offensive player gets to shoot the ball. My problem is that I can't get my program to give me a result other than "Offense does not get to shoot" I've included part of my program below. It's pretty rough and long since I'm really new to programming but I'd really appreciate any help I could get in figuring out where I'm going wrong. The program works up until the point where it tells me if the offense gets to score. Thanks!!
Dim homeplayeroffensestat(4) As Integer
Dim homeplayerdefensestat(4) As Integer
Dim homeplayershootingstat(4) As Integer
Dim awayplayeroffensestat(4) As Integer
Dim awayplayerdefensestat(4) As Integer
Dim awayplayershootingstat(4) As Integer
'convert numbers in textboxes to integers
Static isconverted As Boolean
isconverted = Integer.TryParse(Label37.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayeroffensestat(0))
isconverted = Integer.TryParse(Label38.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayerdefensestat(1))
isconverted = Integer.TryParse(Label39.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayershootingstat(2))
isconverted = Integer.TryParse(Label40.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayeroffensestat(3))
isconverted = Integer.TryParse(Label41.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayeroffensestat(4))
isconverted = Integer.TryParse(Label42.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayeroffensestat(0))
isconverted = Integer.TryParse(Label43.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayeroffensestat(1))
isconverted = Integer.TryParse(Label44.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayerdefensestat(2))
isconverted = Integer.TryParse(Label45.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayerdefensestat(3))
isconverted = Integer.TryParse(Label46.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayerdefensestat(4))
isconverted = Integer.TryParse(Label47.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayerdefensestat(0))
isconverted = Integer.TryParse(Label48.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayershootingstat(1))
isconverted = Integer.TryParse(Label49.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayershootingstat(2))
isconverted = Integer.TryParse(Label50.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayershootingstat(3))
isconverted = Integer.TryParse(Label51.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, homeplayershootingstat(4))
isconverted = Integer.TryParse(Label52.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayeroffensestat(0))
isconverted = Integer.TryParse(Label53.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayeroffensestat(1))
isconverted = Integer.TryParse(Label54.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayeroffensestat(2))
isconverted = Integer.TryParse(Label55.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayeroffensestat(3))
isconverted = Integer.TryParse(Label56.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayeroffensestat(4))
isconverted = Integer.TryParse(Label57.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayerdefensestat(0))
isconverted = Integer.TryParse(Label58.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayerdefensestat(1))
isconverted = Integer.TryParse(Label59.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayerdefensestat(2))
isconverted = Integer.TryParse(Label60.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayerdefensestat(3))
isconverted = Integer.TryParse(Label61.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayerdefensestat(4))
isconverted = Integer.TryParse(Label62.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayershootingstat(0))
isconverted = Integer.TryParse(Label63.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayershootingstat(1))
isconverted = Integer.TryParse(Label64.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayershootingstat(2))
isconverted = Integer.TryParse(Label65.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayershootingstat(3))
isconverted = Integer.TryParse(Label66.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, awayplayershootingstat(4))
'randomly pick two players to compete
Dim homeplayer As Integer
Dim awayplayer As Integer
Dim randomgenerator As New Random
homeplayer = randomgenerator.Next(0, 5)
awayplayer = randomgenerator.Next(0, 5)
If homeplayer = 0 Then Label67.Text = "Michelle Johnson" Else
If homeplayer = 1 Then Label67.Text = "Jennifer Smith" Else
If homeplayer = 2 Then Label67.Text = "Jessica Doe" Else
If homeplayer = 3 Then Label67.Text = "Rebecca Clark" Else
If homeplayer = 4 Then Label67.Text = "Allison James"
If awayplayer = 0 Then Label69.Text = "Monica Hargrove" Else
If awayplayer = 1 Then Label69.Text = "Micah Manning" Else
If awayplayer = 2 Then Label69.Text = "Amberly Thompson" Else
If awayplayer = 3 Then Label69.Text = "Linda Reynolds" Else
If awayplayer = 4 Then Label69.Text = "Brenda Cheatem"
'pick which team is offense and which is defense
Dim offense As Integer
Dim randomgenerator2 As New Random
offense = randomgenerator2.Next(0, 2)
If offense = 0 Then Label72.Text = "Offense"
If offense = 0 Then Label73.Text = "Defense"
If offense = 1 Then Label72.Text = "Defense"
If offense = 1 Then Label73.Text = "Offense"
'compare the offensive and defensive ranks to decide if offense gets to shoot
Dim homeplyr(4) As Boolean
Dim awayplyr(4) As Boolean
Dim hometeamisoffense As Boolean
Dim awayteamisoffense As Boolean
If Label72.Text = "Offense" Then
hometeamisoffense = True
ElseIf Label72.Text = "Defense" Then
awayteamisoffense = True
End If
If hometeamisoffense = True AndAlso Label67.Text = "Michelle Johnson" Then
homeplyr(0) = True
ElseIf hometeamisoffense = True AndAlso Label67.Text = "Jennifer Smith" Then
homeplyr(1) = True
ElseIf hometeamisoffense = True AndAlso Label67.Text = "Jessica Doe" Then
homeplyr(2) = True
ElseIf hometeamisoffense = True AndAlso Label67.Text = "Rebecca Clark" Then
homeplyr(3) = True
ElseIf hometeamisoffense = True AndAlso Label67.Text = "Allison James" Then
homeplyr(4) = True
End If
If awayteamisoffense = True AndAlso Label69.Text = "Monica Hargrove" Then
awayplyr(0) = True
ElseIf awayteamisoffense = True AndAlso Label69.Text = "Micah Manning" Then
awayplyr(1) = True
ElseIf awayteamisoffense = True AndAlso Label69.Text = "Amberly Thompson" Then
awayplyr(2) = True
ElseIf awayteamisoffense = True AndAlso Label69.Text = "Linda Reynolds" Then
awayplyr(3) = True
ElseIf awayteamisoffense = True AndAlso Label69.Text = "Brenda Cheatem" Then
awayplyr(4) = True
End If
Dim matchup(24) As Boolean
If homeplyr(0) = True AndAlso awayplyr(0) = True Then
matchup(0) = True
ElseIf homeplyr(0) = True AndAlso awayplyr(1) = True Then
matchup(1) = True
ElseIf homeplyr(0) = True AndAlso awayplyr(2) = True Then
matchup(2) = True
ElseIf homeplyr(0) = True AndAlso awayplyr(3) = True Then
matchup(3) = True
ElseIf homeplyr(0) = True AndAlso awayplyr(4) = True Then
matchup(4) = True
ElseIf homeplyr(1) = True AndAlso awayplyr(0) = True Then
matchup(5) = True
ElseIf homeplyr(1) = True AndAlso awayplyr(1) = True Then
matchup(6) = True
ElseIf homeplyr(1) = True AndAlso awayplyr(2) = True Then
matchup(7) = True
ElseIf homeplyr(1) = True AndAlso awayplyr(3) = True Then
matchup(8) = True
ElseIf homeplyr(1) = True AndAlso awayplyr(4) = True Then
matchup(9) = True
ElseIf homeplyr(2) = True AndAlso awayplyr(0) = True Then
matchup(10) = True
ElseIf homeplyr(2) = True AndAlso awayplyr(1) = True Then
matchup(11) = True
ElseIf homeplyr(2) = True AndAlso awayplyr(2) = True Then
matchup(12) = True
ElseIf homeplyr(2) = True AndAlso awayplyr(3) = True Then
matchup(13) = True
ElseIf homeplyr(2) = True AndAlso awayplyr(4) = True Then
matchup(14) = True
ElseIf homeplyr(3) = True AndAlso awayplyr(0) = True Then
matchup(15) = True
ElseIf homeplyr(3) = True AndAlso awayplyr(1) = True Then
matchup(16) = True
ElseIf homeplyr(3) = True AndAlso awayplyr(2) = True Then
matchup(17) = True
ElseIf homeplyr(3) = True AndAlso awayplyr(3) = True Then
matchup(18) = True
ElseIf homeplyr(3) = True AndAlso awayplyr(4) = True Then
matchup(19) = True
ElseIf homeplyr(4) = True AndAlso awayplyr(0) = True Then
matchup(20) = True
ElseIf homeplyr(4) = True AndAlso awayplyr(1) = True Then
matchup(21) = True
ElseIf homeplyr(4) = True AndAlso awayplyr(2) = True Then
matchup(22) = True
ElseIf homeplyr(4) = True AndAlso awayplyr(3) = True Then
matchup(23) = True
ElseIf homeplyr(4) = True AndAlso awayplyr(4) = True Then
matchup(24) = True
End If
Static matchupshoot(49) As Boolean
If matchup(0) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(0) > awayplayerdefensestat(0) Then
matchupshoot(0) = True
ElseIf matchup(1) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(0) > awayplayerdefensestat(1) Then
matchupshoot(1) = True
ElseIf matchup(2) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(0) > awayplayerdefensestat(2) Then
matchupshoot(2) = True
ElseIf matchup(3) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(0) > awayplayerdefensestat(3) Then
matchupshoot(3) = True
ElseIf matchup(4) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(0) > awayplayerdefensestat(4) Then
matchupshoot(4) = True
ElseIf matchup(5) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(1) > awayplayerdefensestat(0) Then
matchupshoot(5) = True
ElseIf matchup(6) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(1) > awayplayerdefensestat(1) Then
matchupshoot(6) = True
ElseIf matchup(7) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(1) > awayplayerdefensestat(2) Then
matchupshoot(7) = True
ElseIf matchup(8) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(1) > awayplayerdefensestat(3) Then
matchupshoot(8) = True
ElseIf matchup(9) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(1) > awayplayerdefensestat(4) Then
matchupshoot(9) = True
ElseIf matchup(10) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(2) > awayplayerdefensestat(0) Then
matchupshoot(10) = True
ElseIf matchup(11) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(2) > awayplayerdefensestat(1) Then
matchupshoot(11) = True
ElseIf matchup(12) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(2) > awayplayerdefensestat(2) Then
matchupshoot(12) = True
ElseIf matchup(13) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(2) > awayplayerdefensestat(3) Then
matchupshoot(13) = True
ElseIf matchup(14) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(2) > awayplayerdefensestat(4) Then
matchupshoot(14) = True
ElseIf matchup(15) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(3) > awayplayerdefensestat(0) Then
matchupshoot(15) = True
ElseIf matchup(16) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(3) > awayplayerdefensestat(1) Then
matchupshoot(16) = True
ElseIf matchup(17) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(3) > awayplayerdefensestat(2) Then
matchupshoot(17) = True
ElseIf matchup(18) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(3) > awayplayerdefensestat(3) Then
matchupshoot(18) = True
ElseIf matchup(19) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(3) > awayplayerdefensestat(4) Then
matchupshoot(19) = True
ElseIf matchup(20) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(4) > awayplayerdefensestat(0) Then
matchupshoot(20) = True
ElseIf matchup(21) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(4) > awayplayerdefensestat(1) Then
matchupshoot(21) = True
ElseIf matchup(22) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(4) > awayplayerdefensestat(2) Then
matchupshoot(22) = True
ElseIf matchup(23) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(4) > awayplayerdefensestat(3) Then
matchupshoot(23) = True
ElseIf matchup(24) = True AndAlso hometeamisoffense = True AndAlso homeplayeroffensestat(4) > awayplayerdefensestat(4) Then
matchupshoot(24) = True
ElseIf matchup(0) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(0) < awayplayerdefensestat(0) Then
matchupshoot(25) = True
ElseIf matchup(1) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(0) < awayplayerdefensestat(1) Then
matchupshoot(26) = True
ElseIf matchup(2) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(0) < awayplayerdefensestat(2) Then
matchupshoot(27) = True
ElseIf matchup(3) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(0) < awayplayerdefensestat(3) Then
matchupshoot(28) = True
ElseIf matchup(4) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(0) < awayplayerdefensestat(4) Then
matchupshoot(29) = True
ElseIf matchup(5) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(1) < awayplayerdefensestat(0) Then
matchupshoot(30) = True
ElseIf matchup(6) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(1) < awayplayerdefensestat(1) Then
matchupshoot(31) = True
ElseIf matchup(7) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(1) < awayplayerdefensestat(2) Then
matchupshoot(32) = True
ElseIf matchup(8) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(1) < awayplayerdefensestat(3) Then
matchupshoot(33) = True
ElseIf matchup(9) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(1) < awayplayerdefensestat(4) Then
matchupshoot(34) = True
ElseIf matchup(10) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(2) < awayplayerdefensestat(0) Then
matchupshoot(35) = True
ElseIf matchup(11) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(2) < awayplayerdefensestat(1) Then
matchupshoot(36) = True
ElseIf matchup(12) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(2) < awayplayerdefensestat(2) Then
matchupshoot(37) = True
ElseIf matchup(13) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(2) < awayplayerdefensestat(3) Then
matchupshoot(38) = True
ElseIf matchup(14) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(2) < awayplayerdefensestat(4) Then
matchupshoot(39) = True
ElseIf matchup(15) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(3) < awayplayerdefensestat(0) Then
matchupshoot(40) = True
ElseIf matchup(16) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(3) < awayplayerdefensestat(1) Then
matchupshoot(41) = True
ElseIf matchup(17) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(3) < awayplayerdefensestat(2) Then
matchupshoot(42) = True
ElseIf matchup(18) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(3) < awayplayerdefensestat(3) Then
matchupshoot(43) = True
ElseIf matchup(19) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(3) < awayplayerdefensestat(4) Then
matchupshoot(44) = True
ElseIf matchup(20) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(4) < awayplayerdefensestat(0) Then
matchupshoot(45) = True
ElseIf matchup(21) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(4) < awayplayerdefensestat(1) Then
matchupshoot(46) = True
ElseIf matchup(22) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(4) < awayplayerdefensestat(2) Then
matchupshoot(47) = True
ElseIf matchup(23) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(4) < awayplayerdefensestat(3) Then
matchupshoot(48) = True
ElseIf matchup(24) = True AndAlso hometeamisoffense = False AndAlso homeplayeroffensestat(4) < awayplayerdefensestat(4) Then
matchupshoot(49) = True
End If
If matchupshoot(0) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(1) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(2) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(3) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(4) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(5) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(6) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(7) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(8) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(9) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(10) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(11) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(12) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(13) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(14) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(15) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(16) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(17) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(18) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(19) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(20) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(21) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(22) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(23) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(24) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(25) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(26) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(27) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(28) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(29) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(30) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(31) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(32) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(33) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(34) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(35) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(36) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(37) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(38) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(39) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(40) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(41) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(42) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(43) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(44) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(45) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(46) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(47) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(48) = True Then
Label74.Text = "Offense takes a shot!"
ElseIf matchupshoot(49) = True Then
Label74.Text = "Offense takes a shot!"
Else : Label74.Text = "Offense does not get to shoot!"
End If