need to code a linq statement that codes the grade display button so it allows the user to display either all records or only records matching a specific grade. Also it has to calculate a gpa where a=4 b=3 c=2 d=1 f=0 My main problem is with a linq statement how do i define grade into an integer?

This is what I have tried so far:

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
    Dim GPA As Integer = Aggregate CreditHours In CoursesDataSet.tblCourses
                         Select CreditHours * Grade
    Into sum()


    MessageBox.Show("GPa:" & GPA.ToString("C2"),
                   "College Courses", MessageBoxButtons.OK,
                   MessageBoxIcon.Information)
End Sub

below is a pic of the project
Click Here

Click Here

I have retried and now i am getting an error saying grade is not declared. How do i incorporate grade?

Dim GPA As Integer = Aggregate CreditHours In CoursesDataSet.tblCourses
                          Let gradeValue = If(Grade = "A", 4, If(Grade = "B", 3, If(Grade = "C", 2, If(Grade = "D", 1, 0))))
                          Select CreditHours * gradeValue
                          Into Sum()



        MessageBox.Show("GPa:" & GPA.ToString("C2"),
                       "College Courses", MessageBoxButtons.OK,
 MessageBoxIcon.Information)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.