Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Friday, July 15, 2011

VB-43 : To determine whether a student is passed or not

Design a VB application to take input of 5 subjects marks,calculate the total,average and give the grade accordingly.

Refer Program to calculate a student's grade also.

A)    Program Design : 



(B) Property(Controls Used) :
  •      8 Labes and whose captions are Maths,Science,English,Computer,Social,Total,Average and Grade
  •       8 Text Boxes ( (1)The Text Property of the first 7 text boxes should be kept ZERO, and the 8th one is Blank... (2)The Index property of the first 5 text box have to give from ZERO to FOUR...  (3)The Locked property of the last 3 text boxes should be kept as True).

  Grade is calculated on the following basis.
   Fail                : IF (fail in any subject)
Passed             : Average mark is  <50 and >=40
Second Class  :Average mark is  <60 and >=50
First Class     : Average mark is  <70 and >=60
Distinction     : Average mark is  >=70


(C) Attaching Code to the Object :

Private Sub Text1_Change(Index As Integer)
cal_total
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
SendKeys (Chr(8))
End If
End Sub
Private Sub cal_total()
Dim i As Integer
Dim sum As Integer
Dim f As Boolean
f = False

For i = 0 To 4
sum = sum + Val(Text1(i).Text)
If Val(Text(i).Text) < 40 Then
f = True
End If
Next
Text6 = sum
Text7 = sum / 5
If f = True Then
Text8 = "Fail"
ElseIf Val(Text7) >= 70 Then
Text8 = "Distinction"
ElseIf Val(Text7) >= 60 Then
Text8 = "First Class"
ElseIf Val(Text7) >= 50 Then
Text8 = "Second Class"
Else
Text8 = "Pass"
End If
End Sub
Private Sub Text1_LostFocus()
If Val(Text1(Index).Text) > 100 Or Val(Text1(Index).Text) < 0 Then
MsgBox " Marks should be between 0 and 100,Please varify"
Text1(Index).SetFocus
End If
End Sub

====================================================================
===========================================================

No comments: