Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to operate SUMAND AVERAGE operation in datagridview?

hi! Can someone help me with my proposed study. I have a column in a datagrid to be sum up but I dunno knoe how to perform the sum operation in datagrid and average at the same time.. :))
--
I have a field column (Course Code,Unit,Grade,Remarks) I just use a query for the Unit.. I need to add the units having a grade of 5.00 or 4.00 then divide it with the total units of subject enrolled.. I've tried to use a query in access but when I connect it to vb6 the error is type mismatch :)) I dunno if my code is correct

My code is like this:

Private Sub cmdcompute_Click()
Dim sumtotal As String
Dim sumfail As String
Dim avg As Integer

sumfail = "SELECT Sum(Curriculum_entries.Unit)" & _
"FROM Student_pros INNER JOIN Curriculum_entries ON Curriculum_entries.Course_code=Student_pros.Course_code" & _
"WHERE Curriculum_entries.Unit='" & dtpros.Columns(5).Text & "' AND Grade >= 4.00"

sumtotal = "SELECT Sum(Curriculum_entries.Unit)" & _
"FROM Student_pros INNER JOIN Curriculum_entries ON Curriculum_entries.Course_code=Student_pros.Course_code" & _
"WHERE Curriculum_entries.Unit='" & dtpros.Columns(5).Text & "' AND Student_pros.Grade >= 4.00" & Me.dtpros.Columns(6).Text & "'"

avg = (sumfail / sumtotal) * 100

If avg <= 24 Then
txtstatus.Text = "Regular"
Exit Sub
ElseIf 25 >= avg <= 49 Then
txtstatus.Text = "Warning"
Exit Sub
ElseIf 50 >= avg <= 74 Then
txtstatus.Text = "Probation"
Exit Sub
ElseIf avg >= 75 Then
txtstatus.Text = "Dismissal"
End If

End Sub
Sign In or Register to comment.