469,889 Members | 1,505 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,889 developers. It's quick & easy.

How to code for check boxes to select more than one answer?

Hi folks!

Can anyone please help me with this?

I am developing a Quiz program but I am stuck with "multiple answers".
Basically I need some sort of code that would select multiple answers
using check boxes.

For example, a question such as

Which two of the following are relational databases?
A. Oracle
B. UML
C. ODBC
D. Ingres

It should track as A and D.

Can anyone please show a code that would track them two answers?

Also, how does the question bank (in the form of a database) looks
for; i.e. How do you store multiple answers in a database so VB tracks
those answers?

Thanks for your help
Jul 17 '05 #1
4 3423
> Hi folks!

Can anyone please help me with this?

I am developing a Quiz program but I am stuck with "multiple answers".
Basically I need some sort of code that would select multiple answers
using check boxes.

For example, a question such as

Which two of the following are relational databases?
A. Oracle
B. UML
C. ODBC
D. Ingres

It should track as A and D.

Can anyone please show a code that would track them two answers?

Also, how does the question bank (in the form of a database) looks
for; i.e. How do you store multiple answers in a database so VB tracks
those answers?

Thanks for your help


I don't know if it's the best way, but i would track the answers by
representing the whole thing as a single number. I would assign each letter
to a number, probably like this

A = 1
B = 10
C = 100
D = 1000

Then have some code that went through every check box, and added the value
of the each ticked check box to a sum.

Something like this

Answer = 0
if MyCheckA = True then
Answer = Answer + 1
end if
if MyCheckB = True then
Answer = Answer + 10
end if
if MyCheckC = True then
Answer = Answer + 100
end if
if MyCheckD = True then
Answer = Answer + 1000
end if

forgive my code it's late and i'm well beyond tired :(

So if they ticked the correct boxes, you should end up with an Answer of
1001 which you could check against the stored correct answer. It would get
more tricky if they get some points for ticking one of the correct boxes but
not the other one, and trickier still if they loose points for ticking the
wrong one(s). In that case it might be better to keep each answer as a
boolean value in it's own variable/field.

Steve
Jul 17 '05 #2

"Stephen Williams" <st*****@hotmail.com> wrote in message
news:y5********************@news02.tsnz.net...
Also, how does the question bank (in the form of a database) looks
for; i.e. How do you store multiple answers in a database so VB tracks those answers?
It would get
more tricky if they get some points for ticking one of the correct

boxes but not the other one, and trickier still if they loose points for ticking the wrong one(s). In that case it might be better to keep each answer as a boolean value in it's own variable/field.


I would go ahead and do separate fields for each answer. Sooner or later
there will be a reason for it, so you might as well get it set up now.
The table structure could be:
Question Text
ChoiceCnt Long
ChoiceA Text
ChoiceB Text
ChoiceC Text
ChoiceD Text
ChoiceE Text
ChoiceF Text
AnswerA Boolean
AnswerB Boolean
AnswerC Boolean
AnswerD Boolean
AnswerE Boolean
AnswerF Boolean
Jul 17 '05 #3

"Mohammed Mazid" <ka******@hotmail.com> wrote in message
news:7c**************************@posting.google.c om...
Hi folks!

Can anyone please help me with this?

I am developing a Quiz program but I am stuck with "multiple answers".
Basically I need some sort of code that would select multiple answers
using check boxes.

For example, a question such as

Which two of the following are relational databases?
A. Oracle
B. UML
C. ODBC
D. Ingres

It should track as A and D.

Can anyone please show a code that would track them two answers?

Also, how does the question bank (in the form of a database) looks
for; i.e. How do you store multiple answers in a database so VB tracks
those answers?

Thanks for your help


This is just my humble opinion after many years designing user interface and
dealt with automated exams. It probably be against a comon user interface to
have a multiple choice takes multiple answers. A multiple choice should use
an option (radio) button rather than a checkbox. A multiple choice that
takes multiple answers should then be designed like this:

Which two of the following are relational databases?
A. Oracle
B. UML
C. ODBC
D. Ingres
E. A and D

It wouls even be better to have "None of these" as one of the choices. The
design of the questions would make it so much easier in coding especially
when you have answers such as "All of these" (all of the above).

Jul 17 '05 #4
ka******@hotmail.com (Mohammed Mazid) wrote in
news:7c**************************@posting.google.c om:

Hi folks!

Can anyone please help me with this?

I am developing a Quiz program but I am stuck with "multiple answers".
Basically I need some sort of code that would select multiple answers
using check boxes.

For example, a question such as

Which two of the following are relational databases?
A. Oracle
B. UML
C. ODBC
D. Ingres

It should track as A and D.


Use a binary value for each answer,
A=1
B=2
C=4
D=8

Answers can be stored as an integer in this case, and when a question is
posed to the student you can have some code determine if it is multiple
choice or not and show checkboxes or option buttons as appropriate (based
on the correct answer).

Carl
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Stephen Miller | last post: by
1 post views Thread by Daveyk0 | last post: by
3 posts views Thread by somethings.amiss | last post: by
2 posts views Thread by simon.wilkinson | last post: by
lee123
16 posts views Thread by lee123 | last post: by
11 posts views Thread by Patrick | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.