skip to main |
skip to sidebar
AIM:To prepare an online quiz program
PROCEDURE
Select add-ins
->Visual data manager
->file
->new
->Microsoft Access
->Version.7.7. MDB
QUIZ TABLE
SLNO FIELDS DATATYPE
1 QNO LONG
2 QUESTION TEXT
3 OPTION 1 TEXT
4 OPTION 2 TEXT
5 OPTION 3 TEXT
6 OPTION 4 TEXT
7 ANS TEXT
CODE
Form 1
Private Sub examination_Click()
Form3.Show
End Sub
Private Sub question_Click()
Form2.Show
End Sub
Private Sub quit_Click()
End
End Sub
Form 2
Private Sub Command1_Click()
Data.Recordset.AddNew
With Data.Recordset
.Fields("qno") = Text1.Text
.Fields("question") = Text2.Text
.Fields("option1") = Text4.Text
.Fields("option2") = Text5.Text
.Fields("option3") = Text6.Text
.Fields("option4") = Text7.Text
.Fields("ans") = Text3.Text
End With
Data.Recordset.Update
End Sub
Private Sub Command2_Click()
Data.Recordset.Delete
Data.Recordset.MoveNext
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub
Private Sub Command4_Click()
Form1.Show
End Sub
Form 3
Dim a As Integer, answer As String, mark As Integer
Private Sub Command1_Click()
Form1.Show
End Sub
Private Sub Option1_Click(Index As Integer)
answer = Option1(Index).Caption
If answer = Data.Recordset.Fields("answer") Then
label4.Caption = "right answer"
mark = mark + 1
Else
label4.Caption = "wrong answer"
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Option1(1).Value = False
Option2(2).Value = False
Option3(3).Value = False
Option4(4).Value = False
label4.Caption = ""
a = Text1.Text
Data.Refresh
Data.Recordset.MoveFirst
With Data.Recordset
While Not .EOF
If a = .Fields("qno") Then
Label2.Caption = .Fields("qno")
Label3.Caption = .Fields("question")
Option1(1).Caption = .Fields("option1")
Option2(2).Caption = .Fields("option2")
Option3(3).Caption = .Fields("option3")
Option4(4).Caption = .Fields("option4")
Exit Sub
Else
.MoveNext
End If
End Sub
1 comments:
wow this site is superb
Post a Comment