I have been trying to figure this out as the instructor is of no help in his teaching. Need to declare variables for the average score and the letter grade. Calculate the average, use IF/ElseIF statements to determine the letter grade, and return the letter grade. The Private Function CalculateGrade is where this needs placed. Create a subprocedure for the click event for btnDisplay button. It should call the CalculateGrade function with three arguments( the three test scores from the text boxes), and display the returned value in the lblGrade box. A=> 90, B =80 but < 90, C =70 < 80, D =60 < 70 and F <60
The attached file is what the program looks like.
Public Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub txtTest1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTest1.KeyPress
' allows the text box to accept only numbers, the period, and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." _
AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub txtTest2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTest2.KeyPress
' allows the text box to accept only numbers, the period, and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." _
AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub txtTest3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTest3.KeyPress
' allows the text box to accept only numbers, the period, and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." _
AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub txtTest1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTest1.TextChanged
lblGrade.Text = String.Empty
End Sub
Private Sub txtTest2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTest2.TextChanged
lblGrade.Text = String.Empty
End Sub
Private Sub txtTest3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTest3.TextChanged
lblGrade.Text = String.Empty
End Sub
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
End Sub
Private Function CalculateGrade(ByVal testScore1 As Decimal, ByVal testScore2 As Decimal, ByVal testScore3 As Decimal) As String
End
End Function
End Class