Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 17893
Number of posts: 55253

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to operate SUMAND AVERAGE operation in datagridview? Posted by krazieYNEJ on 16 Jan 2012 at 5:45 AM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.