Option Explicit
'JEARVON DHARRIE
'Database Project
' 1.Design a student record
' 2.Design a data entry from
' 3.Write "save" code
' 4.Write "load" code
' 5.Design report card form and write "print" code
' 6.Sub Function to compute year to date grades
' 7.Sub Function to compute GPA
'REQUIREMENTS'''''''''''''''''''''''''''''''
'Year to date grade automatically updates.
'If you try to retreive a record without a record number entered
' trap the error.
'GPA is the average of the 6 courses, updates automaticallly.
'5%, 10% weight on honors, AP, respectively.
'Compute class rank, compared to other people on file.
'Ease of use, enter through boxes, menu with hot keys.
'Use common dialog box.
'Save/ Save As option.
'Saving new file brings up Save As box.
'Minimum of 4 records.
'Grade report- honors/AP classes marked with stars.
''''''''''''''''''''''''''''''''''''''''''''
Dim filename As String
'Common dialog box
'''Private Type AddressRecord '62 Bytes
'' Street As String * 40
'' City As String * 15
'' State As String * 2
'' Zip As String * 5
'''End Type
''
''
''
''
'''Private Type Course '61 Bytes
'' Title As String * 20
'' credits As Single
'' courseNumber As String * 3
'' teacher As String * 20
'' kind As String * 1 'A, H, R (AP, Honors, Regular)
'' q1 As Integer
'' q2 As Integer
'' q3 As Integer
'' q4 As Integer
'' exam As Integer
'' ytd As Single
'' comment(2) As Integer
'''End Type
'Private Function GradeToNumber(ByVal arument As String) As Boolean
'
'
'End Function
Private Type Student
lastName As String * 20
firstName As String * 20
middleName As String * 20
age As Integer
gender As String * 1
grade As Integer
rank As Integer
gpa As Single
homeroom As String * 4
hrTeacher As String * 20
counselor As String * 20
absent As Single
tardy As Integer
' class(9) As Course
idNumber As String * 5
Title1 As String * 20
Title2 As String * 20
Title3 As String * 20
Title4 As String * 20
Title5 As String * 20
Title6 As String * 20
credits As Single
courseNumber As String * 3
teacher1 As String * 20
teacher2 As String * 20
teacher3 As String * 20
teacher4 As String * 20
teacher5 As String * 20
teacher6 As String * 20
kind1 As String * 1
kind2 As String * 1 'A, H, R (AP, Honors, Regular)
kind3 As String * 1
kind4 As String * 1
kind5 As String * 1
kind6 As String * 1
q1 As Integer
q2 As Integer
q3 As Integer
q4 As Integer
q5 As Integer
q6 As Integer
q7 As Integer
q8 As Integer
q9 As Integer
q10 As Integer
q11 As Integer
q12 As Integer
q13 As Integer
q14 As Integer
q15 As Integer
q16 As Integer
q17 As Integer
q18 As Integer
q19 As Integer
q20 As Integer
q21 As Integer
q22 As Integer
q23 As Integer
q24 As Integer
exam1 As Integer
exam2 As Integer
exam3 As Integer
exam4 As Integer
exam5 As Integer
exam6 As Integer
ytd As Single
comment(2) As Integer
Street As String * 40
City As String * 15
State As String * 40
Zip As String * 5
End Type
Dim s As Student
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtstreet.SetFocus
End If
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtzip.SetFocus
End If
End Sub
Private Sub Combo3_Change(index As Integer)
Debug.Print "Foo bar"
If Val(Combo3(0).Text) = R Then
lblfinal.Caption = Val(txtquarter1(0).Text)
End If
End Sub
Private Sub Label15_Change()
lbl
End Sub
Private Sub Label15_Click()
End Sub
Private Sub lblgpa_Change()
Update
'lblgpa.Caption = ((Val(lblfianl(0)) + Val(lblfianl(1)) + Val(lblfianl(2)) + Val(lblfianl(3)) + Val(lblfianl(4)) + Val(lblfianl(5))) / 6) / 25
End Sub
Private Sub mnucard_Click()
FRMREPORTCARD.Show
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub mnuOpen_Click()
DIALOGS.ShowOpen
Open DIALOGS.filename For Random As #1 Len = Len(s)
s.idNumber = Val(txtid)
Get #1, s.idNumber, s
txtlast.Text = s.lastName
Txtfirst.Text = s.firstName
txtmiddle.Text = s.middleName
txtage = s.age
Combo1 = s.gender
Combo2 = s.State
txtcity.Text = s.City
txtid.Text = s.idNumber
txtstreet.Text = s.Street
txtcounselor.Text = s.counselor
txthomeroomeacher.Text = s.hrTeacher
txthomeroom = s.homeroom
txtzip.Text = s.Zip
txtgrade(9).Text = s.grade
txtrank.Text = s.rank
' For Index = 0 To 5
' txtTeacher(Index).Text = s.teacher
' Next Index
txtTeacher(0) = s.teacher1
txtTeacher(1) = s.teacher2
txtTeacher(2) = s.teacher3
txtTeacher(3) = s.teacher4
txtTeacher(4) = s.teacher5
txtTeacher(5) = s.teacher6
' For Index = 0 To 5
' txtClass(Index) = s.teacher
' Next Index
' For Index = 0 To 5
'Combo3(Index) = s.kind
' Next Index
txtclasstype(0).Text = s.kind1
txtclasstype(1) = s.kind2
txtclasstype(2) = s.kind3
txtclasstype(3) = s.kind4
txtclasstype(4) = s.kind5
txtclasstype(5) = s.kind6
txtClass(0) = s.Title1
txtClass(1) = s.Title2
txtClass(2) = s.Title3
txtClass(3) = s.Title4
txtClass(4) = s.Title5
txtClass(5) = s.Title6
txtquarter1(0) = s.q1
txtquarter1(1) = s.q2
txtquarter1(2) = s.q3
txtquarter1(3) = s.q4
txtquarter1(4) = s.q5
txtquarter1(5) = s.q6
Close #1
'End If
End Sub
Private Sub mnuprint_Click()
DIALOGS.ShowPrinter
End Sub
Private Sub mnusa_Click()
DIALOGS.ShowSave
Open DIALOGS.filename For Random As #1 Len = Len(s)
s.lastName = txtlast
s.idNumber = txtid
s.middleName = txtmiddle.Text
s.age = txtage
Put #1, s.idNumber, s
Close #1
End Sub
Private Sub mnusave_Click()
If filename = "" Then
DIALOGS.ShowSave
filename = DIALOGS.filename
End If
Open DIALOGS.filename For Random As #1 Len = Len(s)
s.lastName = txtlast
s.idNumber = txtid
s.middleName = txtmiddle.Text
s.firstName = Txtfirst
s.age = Val(txtage)
s.gender = Combo1
's.State = Combo2.ItemData
s.City = txtcity.Text
s.Street = txtstreet.Text
s.Zip = txtzip.Text
s.counselor = txtcounselor.Text
s.hrTeacher = txthomeroomeacher.Text
's.grade = txtgrade(9)
s.rank = txtrank
s.homeroom = txthomeroom
'For Index = 0 To 5
's.teacher = txtTeacher(Index)
'Next Index
'For Index = 0 To 5
's.Title = txtClass(Index)
'Next Index
'For Index = 0 To 5
's.kind = Combo3(Index)
'Next Index
'''For Index = 0 To 4
'''s.q1 = txtquarter1(Index)
'''Next Index
s.teacher1 = txtTeacher(0)
s.teacher2 = txtTeacher(1)
s.teacher3 = txtTeacher(2)
s.teacher4 = txtTeacher(3)
s.teacher5 = txtTeacher(4)
s.teacher6 = txtTeacher(5)
s.kind1 = txtclasstype(0)
s.kind2 = txtclasstype(1)
s.kind3 = txtclasstype(2)
s.kind4 = txtclasstype(3)
s.kind5 = txtclasstype(4)
s.kind6 = txtclasstype(5)
s.Title1 = txtClass(0)
s.Title2 = txtClass(1)
s.Title3 = txtClass(2)
s.Title4 = txtClass(3)
s.Title5 = txtClass(4)
s.Title6 = txtClass(5)
s.q1 = txtquarter1(0)
s.q2 = txtquarter1(1)
s.q3 = txtquarter1(2)
s.q4 = txtquarter1(3)
s.q5 = txtquarter1(4)
s.q6 = txtquarter1(5)
Put #1, s.idNumber, s
Close #1
End Sub
Private Sub txtage_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Combo1.SetFocus
End If
End Sub
Private Sub txtcity_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Combo2.SetFocus
End If
End Sub
Private Sub txtclasstype_Change(index As Integer)
'Debug.Print
If (txtclasstype(index).Text) = "R" And validgrade(txtquarter1(index)) And validgrade(txtq2(index)) And validgrade(txtq3(index)) And validgrade(txtq4(index)) Then
Update
''lblfinal(Index).Caption = (Val(txtquarter1(Index)) + Val(txtq2(Index)) + Val(txtq3(Index)) + Val(txtq4(Index)) + Val(txtexam(Index))) / 4
End Sub
Private Sub Txtfirst_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtmiddle.SetFocus
End If
End Sub
'Private Sub txtid_Change()
'If Len(txtid.Text) <= 0 Then txtid.Text = 0
'End Sub
Private Sub txtlast_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtage.SetFocus
End If
End Sub
Private Sub txtmiddle_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtlast.SetFocus
End If
End Sub
Private Sub txtstreet_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtcity.SetFocus
End If
End Sub
Private Function validgrade(ByVal grade As String) As Boolean
grade = Trim$(grade)
validgrade = IsNumeric(grade)
validgrade = True
End Function
Private Sub Update(i)
'Debug.Print "Update
For index = 0 To 5
lblfinal(index) = (Val(txtquarter1(index)) + Val(txtq2(index)) + Val(txtq3(index)) + Val(txtq4(index)) + Val(txtexam(index))) / 4
Next index
If (txtclasstype(index).Text) = "R" And validgrade(txtquarter1(index)) And validgrade(txtq2(index)) And validgrade(txtq3(index)) And validgrade(txtq4(index)) Then
lblfinal(index).Caption = (Val(txtquarter1(index)) + Val(txtq2(index)) + Val(txtq3(index)) + Val(txtq4(index)) + Val(txtexam(index))) / 4
End If
lblgpa.Caption = ((Val(lblfianl(0)) + Val(lblfianl(1)) + Val(lblfianl(2)) + Val(lblfianl(3)) + Val(lblfianl(4)) + Val(lblfianl(5))) / 6) / 25
End Sub