VB Program to save student record and find marks (total, % , grade etc...)

Program to save student records and calculator using DAO

Sample :

I can't show you complete code Directly so download full code from below .
Download the output  for the form (design).

Dim db As Database
Dim rs As Recordset
Dim mark(2 To 4) As Double


Private Sub Cboname_Click()
    searchresult 1, Cboname.Text
End Sub



Private Sub Cborollno_Click()
    searchresult 0, Cborollno.Text
End Sub



Private Sub cmdaddnew_Click()
    textlock False
    rs.AddNew
    Dim i As Integer
    clear
    cmdsave.Enabled = True
End Sub




Private Sub cmdedit_Click()
    If Text(0) <> "" Then
        rs.Edit
        textlock False
        cmdsave.Enabled = True
    Else
        MsgBox ("Please select to edit")
    End If
End Sub



Private Sub cmdsave_Click()
    Dim i As Integer
    For i = 0 To 7
        rs.Fields(i) = Text(i)
    Next i
    rs.Update
    textlock True
    MsgBox ("Save Sucessfully")
    readsearch
End Sub



Private Sub Form_Load()
    Set db = OpenDatabase("Records.mdb")
    Set rs = db.OpenRecordset("data")
    readsearch
    textlock True
End Sub



Private Function readsearch()
    Cborollno.clear
    Cboname.clear
    Dim tem As Recordset
    Set tem = db.OpenRecordset("data")
    While tem.EOF = False
           Cborollno.AddItem (tem.Fields(0))
           Cboname.AddItem (tem.Fields(1))
            tem.MoveNext
    Wend
End Function



Private Function searchresult(x As Integer, s As String)
    rs.MoveFirst
    While (rs.EOF = False) And (rs.Fields(x) <> s)
        rs.MoveNext
    Wend
    Dim i As Integer
    For i = 0 To 7
        Text(i) = rs.Fields(i)
    Next i
End Function



Private Function textlock(b As Boolean)
    Dim i As Integer
    For i = 0 To 7
        Text(i).Locked = b
    Next i
    Framesearch.Enabled = b
End Function



Private Sub Text_Change(Index As Integer)
    Text(5) = Val(Text(2)) + Val(Text(3)) + Val(Text(4))
    Text(6) = Val(Text(5)) / 3
    Select Case Val(Text(6))
        Case Is >= 80
                Text(7) = "Distinction"
        Case Is >= 60
                Text(7) = "First class"
        Case Is >= 50
                Text(7) = "Secound class"
        Case Is < 50
                Text(7) = "Fail"
        End Select
End Sub



Full Code :
Download 
Alternative link
Output(Student.exe)

Download
Alternative link
Full code(Student.doc)

Download
Alternative link
Full project(Student.zip)

*Note Full project require Visual Basic 6.0

0 comments:

Post a Comment