Results 1 to 2 of 2

Thread: Question-Answer program help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2011
    Posts
    27

    Question-Answer program help

    Hi,

    A while ago I wrote a quick and very very simple program to test myself on about 10 questions I needed to remember the answer to. I made a form with a label, text box and button. the label contained the question and the answer was entered into the textbox and the button was pressed to check the answer. the code i used was very similar to this:

    Dim answer As String
    answer = TextBox1.Text
    If answer = "helium" Then
    Label1.Text = "What is the country next to spain?"
    Else : MsgBox("Incorrect")
    End If

    Because I only had 10 questions it was fine to copy and paste the code a few times and rename the questions but now i am going to use this again but for a lot more questions (in the end there will be a couple of hundred) so i was wondering if any one knew a better way to do this? I was thinking maybe an array like 1 to hold the questions and 1 to hold the answers but i haven't worked much with arrays so I'm not sure how difficult this would be ?

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Question-Answer program help

    if you have a lot of data to work with, i suggest using a database.

    you can load all the questions into and array or a list, or you can use key-value pair.

    have a look in MSDN for generic collections - http://msdn.microsoft.com/en-us/libr...s.generic.aspx

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