can anyone tell me the best way to code a program with questions (20) with multiple choice answers (4)
tink
Printable View
can anyone tell me the best way to code a program with questions (20) with multiple choice answers (4)
tink
School assignment?
20 isn't a lot, so you could get away with a simple text file that might look a bit like this...
1st bit being the question, next 4 being possible answers and the last being the correct answer.Code:How many humps does a camel have?;2;15;3;10;2
chrisjk
thanks for the reply, got all the questions , but not sure how to call up the questions, and being 4 possible answers coding it to the right answer eg:
whats the capital of the UK London, Dublin, Bristol, Bath
how do i code to say London?
tink
send us all your questions/answers if you can
I would tweek chrisjk's method just a bit and put the following in my file
Where the 1 indicates the correct answer.Code:whats the capital of the UK London;Dublin;Bristol;Bath;1
If you have VB6 you can use the Split function to break up the line above at the semi-colons. (If you don't have VB 6 you'd haver to split it up yourself). The last entry in the resulting array would then contain 1 and you could use that as the index into the array to display the answer. If that's confusing let me know if you have VB6 or not and I'll do the code for you.
Good point, but then it should probably then be zero basedQuote:
Originally posted by MartinLiss
The last entry in the resulting array would then contain 1 and you could use that as the index into the array to display the answer.
I always think it's easier for the human entering the questions in the text file to think 1-based and have the program just subtract 1.