title: This is an assignment I have to turn in. I am missing something about the function calculation
body: <p>I have three test scores the lowest score will be dropped. A function is used to calculate the final grade and the grade has to be converted from a number to a letter. I have done everything I can I am trying to figure out and make sure that the function is written correctly.</p>
  
  <pre><code>'I put these at public class so they could be used throughout the program
  
  Dim test1 As Double
  Dim test2 As Double
  Dim test3 As Double
  Dim student As String
  Dim Result1 As String
  Dim total As String
  
  
  Function SemesterGrade(ByVal t1 As Double, ByVal t2 As Double, ByVal t3 As Double) As Double
  
      'This function determines the test scores and drops the lowest score from calculation
      If t1 &lt; t2 And t1 &lt; t3 Then
          total = CStr(((t2 + t3) / 2))
  
      ElseIf t2 &lt; t3 And t2 &lt; t1 Then
          total = CStr(((test1 + test3) / 2))
  
      ElseIf t3 &lt; t2 And t3 &lt; t1 Then
          total = CStr(((t1 + t2) / 2))
  
          'I added this if statement to calculate if all the scores were the same because the program would not give me the correct output 
      ElseIf t1 = t2 And t2 = t3 Then
          total = CStr((t1 + t2 + t3) / 3)
  
      End If
  
      'this returns the result from this function
      Return CDbl(total)
  
  
  
  End Function
  
  Private Sub btnDetermine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDetermine.Click
      Dim result As String
      'these pull the information from my textboxes 
      test1 = CDbl(txtFirst.Text)
      test2 = CDbl(txtSecond.Text)
      test3 = CDbl(txtThird.Text)
      student = txtName.Text.ToUpper
  
      'this is how i use the function calculation 
      result = CStr((SemesterGrade(test1, test2, test3)))
  
      'This is to convert the number score to a letter
      If CDbl(total) &gt;= 90 Then
          Result1 = ("A")
      ElseIf CDbl(total) &gt;= 80 Then
          Result1 = "B"
      ElseIf CDbl(total) &gt;= 70 Then
          Result1 = "C"
      ElseIf CDbl(total) &gt;= 60 Then
          Result1 = "D"
      ElseIf CDbl(total) &lt; 60 Then
          Result1 = "F"
  
      End If
  
      'This is the output for the result 
      txtResult.Text = student &amp; ": " &amp; Result1
  
  
  End Sub
  
  End Class
  </code></pre>