Results 1 to 7 of 7

Thread: Make a quiz in visual basic

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    14

    Make a quiz in visual basic

    im trying to make a simple quiz in visual basic

    all it has is a label
    a textbox and two buttons

    one of the buttons if for checking if the answer is rite
    while the other is to go to the next question

    i want to make it so
    when the next question button is clicked the label changes to the next question
    and the textbox is cleared

    and then when i press check it checks the answer

    plz help
    i have no idea how i can do this
    im not very skilled at vb
    plz help

  2. #2
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    Re: Make a quiz in visual basic

    Code:
    Public Class Form
    
        Private _questions As New List(Of Question)
        Private _currentQuestionIndex As Integer = 0
    
        Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            'Make new questions:
            Dim newQuestion As Question
            newQuestion.text = "It is yellow"
            newQuestion.answer = "banana"
            _questions.Add(newQuestion)
    
            'Question at startup
            Label1.Text = _questions(_currentQuestionIndex).text
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Text.Equals(_questions(_currentQuestionIndex).answer) Then
                MsgBox("You have answered right")
            Else
                TextBox1.Text = Nothing
                MsgBox("Try again")
            End If
        End Sub
    
        'Next question button
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Label1.Text = _questions(_currentQuestionIndex + 1).text
            _currentQuestionIndex += 1
    
            TextBox1.Text = Nothing
        End Sub
    
        Structure Question
            Dim text As String
            Dim answer As String
        End Structure
    
    End Class
    Here is an example.. It has faults like if you click the button for the next question and there isn't one it will give an error...
    But at least you have something to start with.

    Edit:

    You probaly won't understand all of it so what I would do is follow this tutorial:
    http://www.homeandlearn.co.uk/NET/vbNet.html
    I learned all the basics from that website. It's very clear and easy to read.
    Last edited by gonzalioz; Oct 13th, 2009 at 06:06 AM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    14

    Re: Make a quiz in visual basic

    thanks for that
    but i dont get how can i
    add new questions?
    can u plz help

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    14

    Re: Make a quiz in visual basic

    also wat is
    structure?

  5. #5
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: Make a quiz in visual basic

    It is great that you have come here for answers, however if you need help with your homework, at least be upfront and say "Please Help with Homework!". Then we can actually help you learn so that when the teacher asks you about your code, you can talk about it intelligently and not get stuck trying to explain something you do not understand.

    That being said, I have included some Reading Material on structures that will help you understand what they are and how to use them. Make sure you follow through the link that gonzalioz very graciously posted as well. As he said, that will help you get started.....along with the material your class provides!!!

    Good Luck!

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    14

    Re: Make a quiz in visual basic

    its not really homework
    im doing a project and yes i have read most of the link
    that gonzalioz gave me
    there still a few left but i dont think i will have time to read more
    since the program is due on friday

    also i understand most of the code
    jsut some parts i dont get
    which i asked bout above
    and thanks for the link
    ill check it out =]

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    14

    Re: Make a quiz in visual basic

    ok thanks for all the help guys
    but i dont think i get the one gonzalioz gave me
    but ive thought of a more simpler idea
    that works =]

    thanks for all the help guys =]

    ps if u want to know how i did it
    plz ask

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width