473,416 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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 3583
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mohammed Mazid | last post by:
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...
4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
2
by: Stephen Miller | last post by:
I have a page with many, dynamically generated combo boxes and I want to check all of them, before I add a unique value to specific combo. What would be the best way to work through the document...
1
by: arthur-e | last post by:
How can you select records based on more than one combo box - I have a combobox that selects records based on name (I'm sure this has been asked a thousand times - web site answer/link could be...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
3
by: somethings.amiss | last post by:
I searched google groups for an answer but found none that I could completely understand. I have a table. It contains fields such as 'client,date,hours,project,employee.' I have a form that...
2
by: simon.wilkinson | last post by:
Hi, I am trying to update all Select boxes on a page dynamically using javascript, I simple want to change the selected item in each select box when a tick box is pressed on the page. Each...
16
lee123
by: lee123 | last post by:
how do you use a check box in a form, lets say you have a question (that needs to be answered) on a form and you have three check boxes and one is the right answer and two is wrong answer. if they...
11
by: Patrick | last post by:
Trying this question again in a different way and expanding it to another newsgroup. Looking for how I would do this. For an html form; Say I have three check boxes A, B, and C . When I click...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.