Entrance Exam for Guidance Office

Submitted by: 
Visitors have accessed this post 11041 times.

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:

  1. Imports System.Data.OleDb
  2.  
  3. Public Class frmEntranceExam
  4. Public Property ApplicantID As Integer
  5.  
  6. Dim iLastNewsID As Integer
  7. Dim intCorrectAnswer As Integer
  8.  
  9. Private Sub frmEntranceExam_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  10. If MessageBox.Show("Are you sure you want to quit?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then e.Cancel = True
  11. End Sub
  12.  
  13. Private Sub frmEntranceExam_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  14. Me.EntranceQuestionTableAdapter.Fill(Me.EntranceQuestionDataSet.EntranceQuestion)
  15.  
  16. iLastNewsID = EntranceQuestionDataSet.Tables(0).Compute("Max(QuestionID)", Nothing)
  17. End Sub
  18.  
  19. Private Sub EntranceQuestionBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles EntranceQuestionBindingNavigatorSaveItem.Click
  20. Me.Validate()
  21. Me.EntranceQuestionBindingSource.EndEdit()
  22. Me.TableAdapterManager.UpdateAll(Me.EntranceQuestionDataSet)
  23.  
  24. End Sub
  25.  
  26. Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
  27. InsertAnswer()
  28.  
  29. If QuestionIDTextBox.Text = iLastNewsID Then
  30. ExecNonQuery("UPDATE Applicant SET Score = " & intCorrectAnswer & ", AlreadyTaken = True WHERE ApplicantID = '" & ApplicantID & "'")
  31.  
  32. MessageBox.Show("You have successfully answered all the questions.", "Thank you", MessageBoxButtons.OK, MessageBoxIcon.Information)
  33.  
  34. Me.Close()
  35. Else
  36. BindingNavigatorMoveNextItem.PerformClick()
  37. End If
  38. End Sub
  39.  
  40. Private Sub btnPrevious_Click(sender As System.Object, e As System.EventArgs) Handles btnPrevious.Click
  41. InsertAnswer()
  42.  
  43. BindingNavigatorMovePreviousItem.PerformClick()
  44. End Sub
  45.  
  46. Private Sub InsertAnswer()
  47. Dim intRows As Integer = CountRows("SELECT ResultID FROM ApplicantResult WHERE ApplicantID = '" & ApplicantID & "' AND QuestionID = " & QuestionIDTextBox.Text)
  48. Dim blnCorrectAnswer As Boolean
  49.  
  50. Dim strAnswer As String = ""
  51.  
  52. If AnswerARadioButton.Checked = True Then strAnswer = "A"
  53. If AnswerBRadioButton.Checked = True Then strAnswer = "B"
  54. If AnswerCRadioButton.Checked = True Then strAnswer = "C"
  55. If AnswerDRadioButton.Checked = True Then strAnswer = "D"
  56.  
  57. 'Dim strCorrectAnswer = GetFieldValue("SELECT QuestionID, CorrectAnswer FROM EntranceQuestion WHERE QuestionID=" & QuestionIDTextBox.Text, "CorrectAnswer")
  58.  
  59. If CorrectAnswerTextBox.Text = strAnswer Then
  60. blnCorrectAnswer = True
  61. intCorrectAnswer += 1
  62. End If
  63.  
  64. If intRows = 0 Then
  65. ExecNonQuery("INSERT INTO ApplicantResult (ApplicantID, QuestionID, Answer, Correct) VALUES('" & ApplicantID & "', " & QuestionIDTextBox.Text & ", '" & strAnswer & "'," & blnCorrectAnswer & ")")
  66. Else
  67. ExecNonQuery("UPDATE ApplicantResult SET Answer = '" & strAnswer & "', Correct = " & blnCorrectAnswer & " WHERE ApplicantID = '" & ApplicantID & "' AND QuestionID = " & QuestionIDTextBox.Text)
  68. End If
  69. End Sub
  70.  
  71.  
  72. 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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.