c++

Associate
Joined
29 May 2012
Posts
862
Location
UK
On behalf of a mate

Private Sub cmddisplay_Click()
Cls
Dim Name As String
Dim Assignment1 As Integer
Dim Assignment2 As Integer
Dim Exam As Integer
Dim DateOfBirth As Date
Dim age As Integer
Dim C As Byte
Dim AverageMark As Single
Dim Percentage As Integer
Dim Grade As String
Dim accumulator As Single
Dim BestStudent As String
Dim BestMark As Integer
Dim C_Percentage As Single
' Define output variable Field names


Open App.Path & "\Results2.DAT" For Input As #5 'this opens the DAT file

Print
Print Tab(1); "Name"; Tab(20); "A1 Mark"; Tab(32); "A2 Mark"; Tab(42); "Exam"; Tab(52); "DOB"; Tab(65); "(%)Mark"; Tab(75); "Grade"; Tab(91); "Age";
Do Until EOF(5)
Let C = C + 1
Input #5, Name, Assignment1, Assignment2, Exam, DateOfBirth

Let Percentage = (Assignment1 + Assignment2 + Exam) / 3
' Gives grade to each student
If Percentage >= 80 Then
Let Grade = "D"
End If

If Percentage >= 65 And Percentage < 80 Then
Let Grade = "M"
End If

If Percentage >= 50 And Percenatage < 65 Then
Let Grade = "P"
End If

If Percentage < 50 Then
Let Grade = "U"
End If

Let mark(C) = Percentage
Let student(C) = Name
If BestMark < mark(C) Then ' If statement to calculate best student
Let BestMark = mark(C)
Let BestStudent = student(C)
End If

Let age = Int(((Date - DateOfBirth) / 365))
Print Tab(4); Name; Tab(25); Assignment1; Tab(32); Assignment2; Tab(42); Exam; Tab(52); DateOfBirth; Tab(65); Percentage; Tab(75); Grade; Tab(91); age;

Let C_Percentage = C_Percentage + Percentage

Loop
Close #5
' calculates average percentage of total marks of all students
Let AverageMark = Int(C_Percentage / C)
Print Tab(37); "_____________________"
Print Tab(37); "Average Mark =" & Format$(Format$(AverageMark, "Standard"), "@@@@")

Print
Print AverageMark

lblBestResult.FontSize = 12
lblBestResult.ForeColor = vbRed
lblBestResult.Caption = "Best Student is " & BestStudent & " with a score of" & BestMark & "%"



End Sub
Private Sub lblBestResult_Clic()
End
End Sub




Private Sub cmdlogout_Click()
Me.Hide
Form1.Show
End Sub

Private Sub Form_Load()

is not working, its not caculatin the grade and its keep screw up! HELP!!
 
Back
Top Bottom