πIn this article, I'll show you a programmed, small program with codes. You can analyze the codes.
Let's go to the article
πIn this program, you can enter your exam and practical marks and as an output, you will get an average marks value and it will show whether you pass or fail.
- This is the interface that I have designed
Elements used |
interface |
πLet's go to the codes
Public mth, mpr, mtot, mave As Byte
Public rv As String
Private Sub cmdClose_Click()
rv = MsgBox("Are you sure", vbQuestion + vbYesNo, "Exit")
If rv = vbYes Then
End
End If
End Sub
Private Sub cmdNew_Click()
txtRegNo.Text = ""
txtTheory.Text = ""
txtPractical.Text = ""
lblTotal.Caption = ""
lblAverage.Caption = ""
lblGrade.Caption = ""
End Sub
Private Sub cmdResult_Click()
mtot = mth + mpr
lblTotal.Caption = mtot
lblAverage.Caption = mtot / 2
If mth > 50 And mpr > 50 Then
lblGrade = "pass"
Else
lblGrade = "fail"
End If
End Sub
Private Sub txtPractical_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdResult.SetFocus
End If
End Sub
Private Sub txtPractical_LostFocus()
mpr = Val(txtPractical.Text)
If mpr > 70 Then
lblGradetPractical.Caption = "A"
ElseIf mpr > 60 Then
lblGradetPractical.Caption = "B"
ElseIf mpr > 50 Then
lblGradetPractical.Caption = "C"
ElseIf mpr > 40 Then
lblGradetPractical.Caption = "S"
ElseIf mpr > 25 Then
lblGradetPractical.Caption = "F"
Else: lblGradetPractical.Caption = "E"
End If
If mpr > 100 Then
MsgBox "Invalid data", vbCritical + vbOKOnly, "Error"
txtPractical.Text = ""
txtPractical.SetFocus
End If
End Sub
Private Sub txtRegNo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtTheory.SetFocus
End If
End Sub
Private Sub txtTheory_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPractical.SetFocus
End If
End Sub
Private Sub txtTheory_LostFocus()
mth = Val(txtTheory.Text)
If mth > 70 Then
lblGradeTheory.Caption = "A"
ElseIf mth > 60 Then
lblGradeTheory.Caption = "B"
ElseIf mth > 50 Then
lblGradeTheory.Caption = "C"
ElseIf mth > 40 Then
lblGradeTheory.Caption = "S"
ElseIf mth > 25 Then
lblGradeTheory.Caption = "F"
Else: lblGradeTheory.Caption = "E"
End If
If mth > 100 Then
MsgBox "Invalid Data", vbCritical + vbOKOnly, "Error"
txtTheory.Text = ""
txtTheory.SetFocus
End If
End Sub
πTry and enjoy.
πIf you have any issue with coding contact me
0 Comments