Having a problem. Wrote program originally as VB Console using Sub procedures, had to change it to Function. It worked as sub procedures, but now as function it won't calculate correctly, I actually have two that are doing the same thing because of the procedure switch! Grr! Any suggestions?
Sub Main() 'Declarations Dim dblMidTerm As Double = 0 Dim dblFinal As Double = 0 Dim dblAvgTotal As Double = 0 'Calculate Average dblAvgTotal CalculateTotalAverage(dblMidTerm, dblFinal) ‘Display Average displayTotalAverage(dblAvgTotal) terminateProgram() End Sub Private Sub getExamGrades(ByRef dblMidTerm As Double, ByVal dblFinal As Double) Console.Write("What was your midterm exam numerical grade? ") dblMidTerm = CDbl(Console.ReadLine()) Console.Write("What was your final exam numerical grade? ") dblFinal = CDbl(Console.ReadLíne()) End Sub Private Function CalculateTotalAverage(ByVal dblMidTerm AS Double, ByVal dblFinal As Double) As Double Dim dblAvgTotal As Double = 0 dblAvgTotal = CDbl((dblMidTerm + dblFinal) / 2) Return dblAvgTotal End Function Private Sub displayTotalAverage(ByVal dblAvgTotal As Double) Console.WriteLine("The average of your midterm and Final grades is " & dblAvgTotal) Console.WriteLine() End Sub Private Sub terminateProgram() Console.WriteLine("Press the enter key to terminate program. ") Console. Read() End Sub End Module