Entrance Exam for Guidance Office
Submitted by admin on Sunday, April 21, 2013 - 14:51.
Language
This is an entrance exam developed for Guidance Office. The purpose of this code is to allow the guidance office give a computerized entrance exam for new applicant.
This is just a simple presentation on how you can create the same application.
Features of this system:
Allow applicant to answer questions once only.
Answers are saved automatically to the database when the last question reached.
Sample questionnaire.
Entrance exam results.
Reset applicant’s database table.
Programmed using Visual Basic 2010
Sample Code:
- Imports System.Data.OleDb
- Public Class frmEntranceExam
- Public Property ApplicantID As Integer
- Dim iLastNewsID As Integer
- Dim intCorrectAnswer As Integer
- Private Sub frmEntranceExam_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- If MessageBox.Show("Are you sure you want to quit?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then e.Cancel = True
- End Sub
- Private Sub frmEntranceExam_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- Me.EntranceQuestionTableAdapter.Fill(Me.EntranceQuestionDataSet.EntranceQuestion)
- iLastNewsID = EntranceQuestionDataSet.Tables(0).Compute("Max(QuestionID)", Nothing)
- End Sub
- Private Sub EntranceQuestionBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles EntranceQuestionBindingNavigatorSaveItem.Click
- Me.Validate()
- Me.EntranceQuestionBindingSource.EndEdit()
- Me.TableAdapterManager.UpdateAll(Me.EntranceQuestionDataSet)
- End Sub
- Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
- InsertAnswer()
- If QuestionIDTextBox.Text = iLastNewsID Then
- ExecNonQuery("UPDATE Applicant SET Score = " & intCorrectAnswer & ", AlreadyTaken = True WHERE ApplicantID = '" & ApplicantID & "'")
- MessageBox.Show("You have successfully answered all the questions.", "Thank you", MessageBoxButtons.OK, MessageBoxIcon.Information)
- Else
- BindingNavigatorMoveNextItem.PerformClick()
- End If
- End Sub
- Private Sub btnPrevious_Click(sender As System.Object, e As System.EventArgs) Handles btnPrevious.Click
- InsertAnswer()
- BindingNavigatorMovePreviousItem.PerformClick()
- End Sub
- Private Sub InsertAnswer()
- Dim intRows As Integer = CountRows("SELECT ResultID FROM ApplicantResult WHERE ApplicantID = '" & ApplicantID & "' AND QuestionID = " & QuestionIDTextBox.Text)
- Dim blnCorrectAnswer As Boolean
- Dim strAnswer As String = ""
- If AnswerARadioButton.Checked = True Then strAnswer = "A"
- If AnswerBRadioButton.Checked = True Then strAnswer = "B"
- If AnswerCRadioButton.Checked = True Then strAnswer = "C"
- If AnswerDRadioButton.Checked = True Then strAnswer = "D"
- 'Dim strCorrectAnswer = GetFieldValue("SELECT QuestionID, CorrectAnswer FROM EntranceQuestion WHERE QuestionID=" & QuestionIDTextBox.Text, "CorrectAnswer")
- If CorrectAnswerTextBox.Text = strAnswer Then
- blnCorrectAnswer = True
- intCorrectAnswer += 1
- End If
- If intRows = 0 Then
- ExecNonQuery("INSERT INTO ApplicantResult (ApplicantID, QuestionID, Answer, Correct) VALUES('" & ApplicantID & "', " & QuestionIDTextBox.Text & ", '" & strAnswer & "'," & blnCorrectAnswer & ")")
- Else
- ExecNonQuery("UPDATE ApplicantResult SET Answer = '" & strAnswer & "', Correct = " & blnCorrectAnswer & " WHERE ApplicantID = '" & ApplicantID & "' AND QuestionID = " & QuestionIDTextBox.Text)
- End If
- End Sub
- End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Add new comment
- 269 views