Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

User Input Calculation Change

$
0
0
Hi all,

I'm performing a math calculation to find the handicap of a golfer. Right now I have a constant variable defined for the course rating and slope rating, however, i've given the option of checking a radio button and letting the user enter in their own course and slop rating.

The problem is, it still just reads the constant. Can you help me figure out what I need to do in order to have the user inputted information apply to the formula? This is currently what I have, and it's not working out.

Quote:

Public Class menuScoreperRound

Private golfScores(9) As Double
Dim num As Integer
Dim score As Double
'Default (Muirfield Village Golf Course) Ratings
Dim courseRating As Double = 76.9
Dim slopeRating As Double = 153
Dim par = 72
'Calculations
Dim handicap As Double = (score - courseRating) * 113 / slopeRating + par
Dim usrhandicap As Double = (score - usrCourseRating) * 113 / usrSlopeRating + par
'User Submitted Information
Dim usrCourseRating As Double
Dim usrSlopeRating As Double
Dim customHandicap As Double

Private Sub menuScoreperRound_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.RadioButton1.Checked = True

menuOptions.Hide()
lblHandicap.Visible = False
lblCalcHandi.Visible = False
lblCourseRating.Visible = False
lblSlopeRating.Visible = False

'Custom Numbers from User Input

End Sub


Private Sub btnEnterscore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterscore.Click
clearList()

score = golfScores(num)

golfScores(0) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(1) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(2) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(3) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(4) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(5) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(6) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(7) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(8) = InputBox("Please enter a score.", "Golf Calculator - RS")
golfScores(9) = InputBox("Please enter a score.", "Golf Calculator - RS")


For num As Integer = 0 To golfScores.Length - 1
scoreBox.Items.Add(golfScores(num))
Next

End Sub

Private Sub clearList()
scoreBox.Items.Clear()
End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
clearList()
End Sub

Private Sub btnsortArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsortArray.Click
clearList()
Array.Sort(golfScores)

For num As Integer = 0 To golfScores.Length - 1
scoreBox.Items.Add(golfScores(num))
Next

End Sub

Private Sub btnReversearray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReversearray.Click
clearList()
Array.Reverse(golfScores)
For num As Integer = 0 To golfScores.Length - 1
scoreBox.Items.Add(golfScores(num))
Next
End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
score = (golfScores(num) - courseRating) * slopeRating / 131
'MsgBox("Your Golf Handicap (based on the last 10 rounds) is " & handicap & ".")

Me.lblCalcHandi.Visible = True
Me.lblHandicap.Visible = True


lblHandicap.Text = handicap.ToString("0.00")




End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles RadioButton1.CheckedChanged
Me.Label1.Visible = Me.RadioButton1.Checked
Me.Label2.Visible = Me.RadioButton1.Checked
lblCourseRating.Visible = False
lblSlopeRating.Visible = False
txtCourseRating.Visible = False
txtSlopeRating.Visible = False


End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End Sub

Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
End
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
lblCourseRating.Visible = True
lblSlopeRating.Visible = True
txtCourseRating.Visible = True
txtSlopeRating.Visible = True

If RadioButton2.Checked = True Then
usrCourseRating = courseRating
usrSlopeRating = slopeRating
End If


End Sub

Private Sub txtCourseRating_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCourseRating.TextChanged

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

End Sub

Private Sub lblHandicap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblHandicap.Click

End Sub
End Class

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>