Compute General Weighted Average (GWA) using VB6

The General Weighted Average is a representation (often numerical) of the overall scholastic standing of students used for evaluation. GWA is based on the grades in all subjects taken at a particular level including subjects taken outside of the curriculum. The Philippines has varied university grading systems. Most universities, particularly public institutions, follow the grade point system scale of 5.00 - 1.00, in which 1.00 is the highest grade and 5.00 is the lowest possible grade. In this tutorial, we will make a program that can compute a GWA of a student with a corresponding letter grade. We will make this through computing 20% of prelim, midterm, and prefinal grade and 40% final grade to make it 100%. Now, let's start this tutorial! 1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open. 2.Next, add only one Button named Command1 and labeled it as "Compute". Insert four textboxes named txtPre for inputting the prelim grade, txtMid for inputting the midterm grade, txtPref for inputting the prefinal grade, txtFin for inputting the Final grade. Add also Label named lblGrade for the GWA result and lblLetter for the letter grade view. You must design your interface like this: design 3. Now put this code for your code module.
  1. Option Explicit
  2. Dim preGrade As Integer
  3. Dim midGrade As Integer
  4. Dim prefGrade As Integer
  5. Dim finGrade As Integer
  6. Dim gwa As Double
  7.  
  8. Private Sub cmdCompute_Click()
  9. preGrade = Val(txtPre.Text)
  10. midGrade = Val(txtMid.Text)
  11. prefGrade = Val(txtPref.Text)
  12. finGrade = Val(txtFin.Text)
  13.  
  14. gwa = (preGrade * 0.2) + (midGrade * 0.2) + (prefGrade * 0.2) + (finGrade * 0.4)
  15. lblGrade.Caption = gwa
  16. If txtPre.Text = "" Then
  17. MsgBox "Please fill the missing Grade"
  18. ElseIf txtMid.Text = "" Then
  19. MsgBox "Please fill the missing Grade"
  20. ElseIf txtPref.Text = "" Then
  21. MsgBox "Please fill the missing Grade"
  22. ElseIf txtFin.Text = "" Then
  23. MsgBox "Please fill the missing Grade"
  24. Else
  25. If ((gwa >= 90) And (gwa <= 100)) Then
  26. lblLetter.Caption = "A"
  27. ElseIf ((gwa >= 80) And (gwa <= 89)) Then
  28. lblLetter.Caption = "B"
  29. ElseIf ((gwa >= 75) And (gwa <= 79)) Then
  30. lblLetter.Caption = "C"
  31. ElseIf ((gwa >= 65) And (gwa <= 74)) Then
  32. lblLetter.ForeColor = vbRed
  33. lblLetter.Caption = "D"
  34. Else
  35. lblLetter.ForeColor = vbBlue
  36. lblLetter.Caption = "Out of Range"
  37. End If
  38.  
  39. End If
  40.  
  41. End Sub
  42.  
  43.  
  44.  
  45. Private Sub txtPre_Change()
  46. If IsNumeric(txtPre.Text) = False Then
  47. txtPre.Text = ""
  48. MsgBox "Only accept numbers.", vbOKOnly, "Input Error!"
  49.  
  50. End If
  51. If Val(txtPre.Text) >= 101 Then
  52. MsgBox "Grade out of range.", vbOKOnly, "Error"
  53. End If
  54. End Sub
  55.  
  56. Private Sub txtPref_Change()
  57. If IsNumeric(txtPref.Text) = False Then
  58. txtPref.Text = ""
  59. MsgBox "Only accept numbers.", vbOKOnly, "Input Error!"
  60. End If
  61. If Val(txtPref.Text) >= 101 Then
  62. MsgBox "Grade out of range.", vbOKOnly, "Error"
  63. End If
  64. End Sub
  65.  
  66. Private Sub txtFin_Change()
  67. If IsNumeric(txtFin.Text) = False Then
  68. txtFin.Text = ""
  69. MsgBox "Only accept numbers.", vbOKOnly, "Input Error!"
  70. End If
  71. If Val(txtFin.Text) >= 101 Then
  72. MsgBox "Grade out of range.", vbOKOnly, "Error"
  73. End If
  74. End Sub
  75.  
  76. Private Sub txtMid_Change()
  77. If IsNumeric(txtMid.Text) = False Then
  78. txtMid.Text = ""
  79. MsgBox "Only accept numbers.", vbOKOnly, "Input Error!"
  80. End If
  81. If Val(txtMid.Text) >= 101 Then
  82. MsgBox "Grade out of range.", vbOKOnly, "Error"
  83. End If
  84. End Sub
We have initialized variable preGrade that holds the value of txtPre for grade in prelim, variable midGrade holds the value of txtMid for midterm grade, variable prefGrade holds the value of txtPref for prefinal grade, and variable finGrade holds the value of txtFin for Final grade. Next our variable gwa holds the summation of 20% grade for prelim, 20% grade for midterm, 20% grade for prefinal, and 40% grade for final. We have also initialized the letter grade that will remark the student if they passed or failed in a subject. From 90-100 will be marked as "A", 80-88 has a letter grade of "B", 75-79 as "C", and 65-74 will marked as "D" and it will have a red forecolor in the label which means failed. We make also the code for textchange for textboxes to filter the input as numbers only, and will have no grade of 101 and above.

Output:

outputoutputoutput Download the source code and try it! :) For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment