4. Design an interface, which will appear like marksheet. It will take input of marks in five subjects and calculate total marks and percentage then provide grade according to following criteria. (Using nested if) (Use tab index property to move focus).
If % Then Grade
> = 90 A+
> = 75 & < 90 A
> = 60 & < 75 B
> = 45 & < 60 C
Otherwise F
If % Then Grade
> = 90 A+
> = 75 & < 90 A
> = 60 & < 75 B
> = 45 & < 60 C
Otherwise F
(A)Program Design :
(B) Property(Controls Used) :
- Proper Labels to Text Boxes (Test1 ,Test2,...Project2,Grade...etc)
- 5 TextBoxes - Name-txt_test , Index - 0 to 4
- 6 TextBoxes - Name-txt_prj , Index- 0 to 5
- 3 TextBoxes - Name - txt_total , txt_per & txt_grade , Locked-True
- One Command Button - Caption - Calculate , Name - cmd_cal
(C) Attaching Code to the Object :
Private Sub cmd_cal_Click()
Dim sum As Integer
Dim per As Single
Dim fail As Boolean
fail = False
For i = 0 To 3
sum = sum + Val(txt_test(i).Text)
If Val(txt_test(i).Text) < 35 Then fail = True
Next
txt_test(4) = sum
sum = 0
For i = 0 To 4
If Val(txt_prj(i).Text) < 35 Then fail = True
Next
txt_prj(5) = sum
sum = Val(txt_test(4)) + Val(txt_prj(5))
per = (sum) / 900 * 100
txt_total = sum
txt_per = per
If fail = True Then
txt_grade = "Fail"
Else
Select Case (per)
Case Is >= 70:
txt_grade = "Distinction"
Case Is >= 60:
txt_grade = "First"
Case Is >= 50:
txt_grade = "Second"
Case Else
txt_grade = "Pass"
End If
End Sub
|