I have a linq statement where i turned letter grades into numbers to calculate a gpa can anyone tell me why no matter what grade i click i get the same gpa of 68 for each one? maybe someone can look over my code and give me an answer or hint thanks
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Dim dic As Dictionary(Of String, Integer) = New Dictionary(Of String, Integer)
dic.Add("A", 4)
dic.Add("B", 3)
dic.Add("C", 2)
dic.Add("D", 1)
dic.Add("F", 0)
Dim gpa = Aggregate Grade In CoursesDataSet.tblCourses.AsEnumerable()
Select Grade.Field(Of Integer)("CreditHours") * dic(Grade.Field(Of String)("Grade"))
Into Sum()
MessageBox.Show("GPa:" & gpa.ToString("C2"),
"College Courses", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
End Class