It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

[help] Making a quiz program.

Moderator: dafunkymunky

[help] Making a quiz program.

Postby sean127 on Wed Mar 30, 2011 5:29 pm

:| im making this multiple choices quiz problem, i had most part coded and the question+answers of the quiz are on the .txt file placed in the debug folder.

the purpose is to click next button then the question+answers will change to the next set of the question+answers and i got this part working, but i got troubled on the part where i need to show "correct" or "incorrect" at the end of the test, and it will go into the labels i create, seems only worked for the first question+answers.

also, how can i make it end at the end of the test? it seems the program will keep on going when i click Next button until theres no line to read, then error appear.

last, how can i fit 3 lines of paragraphs on one RichTextBox, it doesn't work when i put all 3 lines together.
and here's the code
Code: Select all
Public Class frm_Lab6c

    Dim Line1(10) As String
    Dim Line2(10) As String
    Dim Line3(10) As String
    Dim Line4(10) As String
    Dim Line5(10) As String
    Dim line6(10) As String
    Dim Line7(10) As String
    Dim Line8(10) As String
    Dim Answer(10) As String

    Dim passagequestion As Integer = 0

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sr As IO.StreamReader = IO.File.OpenText("Summarization Practice Questions 2-11.txt")
        Dim i As Integer = 0
        Do Until sr.EndOfStream

            Line1(i) = sr.ReadLine
            Line2(i) = sr.ReadLine
            Line3(i) = sr.ReadLine
            Line4(i) = sr.ReadLine
            Line5(i) = sr.ReadLine
            line6(i) = sr.ReadLine
            Line7(i) = sr.ReadLine
            Line8(i) = sr.ReadLine
            Answer(i) = sr.ReadLine
            i += 1

        Loop

        txtOne.Text = Line1(0)

        radOne.Text = Line4(0)
        radTwo.Text = Line5(0)
        radThree.Text = line6(0)
        radFour.Text = Line7(0)
        radFive.Text = Line8(0)
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

        Dim msg As String
        Dim title As String
        Dim style As MsgBoxStyle
        Dim response As MsgBoxResult
        msg = "Are you sure you want to quit this test?"
        style = MsgBoxStyle.DefaultButton2 Or _
           MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
        title = "WARNING"
        response = MsgBox(msg, style, title)
        If response = MsgBoxResult.Yes Then
            ExitApplication()
        Else

        End If


    End Sub
    Public Sub ExitApplication()

        If MessageBox.Show("You Have Failed!", "End of the Test", _
              MessageBoxButtons.YesNo, MessageBoxIcon.Error) _
              = DialogResult.Yes Then
            Application.Exit()
        Else
            NotFunctional()
        End If
    End Sub
    Public Sub NotFunctional()
        MessageBox.Show("Too Late, You Already Failed!", "WARNING")
        Application.Exit()
    End Sub


    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
     
        passagequestion += 1
        txtOne.Text = Line1(passagequestion)

        radOne.Text = Line4(passagequestion)
        radTwo.Text = Line5(passagequestion)
        radThree.Text = line6(passagequestion)
        radFour.Text = Line7(passagequestion)
        radFive.Text = Line8(passagequestion)

    End Sub
    Private Sub RadioButtonOne()

        If radOne.Checked = True And Answer(passagequestion) = "1" Then
            lblOne.Text = ("Correct")
        ElseIf radTwo.Checked = True And Answer(passagequestion) = "2" Then
            lblOne.Text = ("Correct")
        ElseIf radThree.Checked = True And Answer(passagequestion) = "3" Then
            lblOne.Text = ("Correct")
        ElseIf radFour.Checked = True And Answer(passagequestion) = "4" Then
            lblOne.Text = ("Correct")
        ElseIf radFive.Checked = True And Answer(passagequestion) = "5" Then
            lblOne.Text = ("Correct")
        Else
            lblOne.Text = ("Incorrect")
        End If
    End Sub
    Private Sub RadioButtonTwo()

        If radTwo.Checked = True And Answer(passagequestion) = "1" Then
            lblTwo.Text = ("Correct")
        ElseIf radTwo.Checked = True And Answer(passagequestion) = "2" Then
            lblTwo.Text = ("Correct")
        ElseIf radThree.Checked = True And Answer(passagequestion) = "3" Then
            lblTwo.Text = ("Correct")
        ElseIf radFour.Checked = True And Answer(passagequestion) = "4" Then
            lblTwo.Text = ("Correct")
        ElseIf radFive.Checked = True And Answer(passagequestion) = "5" Then
            lblTwo.Text = ("Correct")
        Else
            lblTwo.Text = ("Incorrect")
        End If
    End Sub


    Private Sub radOne_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radOne.CheckedChanged
        RadioButtonOne()

    End Sub

    Private Sub radTwo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radTwo.CheckedChanged
        RadioButtonOne()

    End Sub

    Private Sub radThree_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radThree.CheckedChanged
        RadioButtonOne()

    End Sub

    Private Sub radFour_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radFour.CheckedChanged
        RadioButtonOne()

    End Sub

    Private Sub RadioFive_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radFive.CheckedChanged
        RadioButtonOne()

    End Sub



End Class

Thank You
sean127
 
Posts: 1
Joined: Wed Mar 30, 2011 5:25 pm

Who is online

Users browsing this forum: No registered users and 3 guests