0

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

Edited by karodhill

1
Contributor
1
Reply
32
Views
2 Years
Discussion Span
Last Post by karodhill
0

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)

Edited by karodhill

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.