Results 1 to 8 of 8

Thread: VB 2010 - Program for multiple choice test

Threaded View

  1. #8
    Hyperactive Member
    Join Date
    Oct 2010
    Location
    Indiana
    Posts
    457

    Re: VB 2010 - Program for multiple choice test

    Quote Originally Posted by 00brandnew View Post
    but how do I get the program to loop the questions?
    There are many of different ways. You should have already looped through the questions from the text file, so you don't need to loop through them again, you simply change the index of the array to get to the questions you want. One of the simplest would be to set a Public Variable so that when the user first starts the test it the variable is 0, then add 4 to it every time they navigate to the next question. (You use the variable to reference the Array instead of the numeric values).
    Like:
    Code:
    Public X as string
    
    
    Formload event
     X=0
    
    Textbox1.Text = lines(x)
    
    Dim x1 as string
          X1 = x+1
    Dim x2 as string
          X2 = X+2
    lstAnswers.Items.Add(lines(x1))
    lstAnswers.Items.Add(lines(x2))
    etc...
    
    
    
    
    
    For the "Next Question" Event
         X = X+4
    
    Dim x1 as string
          X1 = x+1
    Dim x2 as string
          X2 = X+2
    lstAnswers.Items.Add(lines(x1))
    lstAnswers.Items.Add(lines(x2))
    etc...
    There's more code you will have to add (such as figuring out if your on the last question). Hopefully this gives you a place to start...

    Quote Originally Posted by 00brandnew View Post
    how would I save the answer that the user selects so that I can compute the score at the end?

    we haven't covered databases in my class so we're not allowed to use it for this particular program. Is there a way to do with the text files?
    Again, there is a multitude of ways, but it depends on how you are trying to accomplish it, and what you can use.

    I would assume you want to store the info for later retrieval. The simplest thing would be to can wright it to a text file, and have it so when they sign in it stores their name, and date first (That way it makes it easier to search), then stores the answer with some sort of a flag, like a yes or no if they got it wrong or right.

    You might want to look up XML and using "Tags," it makes it easier to search through txt files...
    Last edited by nO_OnE; Apr 6th, 2011 at 09:16 PM.

Tags for this Thread

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