Making a Multiple Choice Test

Hey guys, I’m quite new with the Xojo language, so please bear with my incompetence :frowning:

So I’m writing a multiple choice test for a program I’ve been working on. It’s a school project. Anyways, I did make one using Visual Basic like 4 years ago, but I guess my code doesn’t work here for some reason, or maybe I rewrote it differently. Can you guys check it? Thanks!

So by the end of the quiz, the person has to click on a button.
The Event Handler is Action:

Private Sub
Dim mark As Integer
mark = 0
if ChoiceAminoAcids.value = True Then mark = mark + 1
if ChoiceProteins.value = True Then mark = mark + 1

ScoreAminoAcids.Caption = mark

End

The score should show in a text box that is unchangeable by the user on the label named ScoreAminoAcids, which somehow, I can’t also do.

Thanks for the response

EDIT: Or instead of using radio buttons for choices, can you suggest any other way to do so? Apparently, when you click on an answer on the second number, the first number’s choice also gets changed. :frowning:

I may not be following you completely but:

.Caption is a string and mark is an integer so I would think that: ScoreAminoAcids.Caption = mark would not have matching types.

Also I am confused as to what ScoreAminoAcids actually is. Is this a Label? Is this a Button? Is this a Text Field?

What is the name of the control that contains the code you have provided? If the ScoreAminoAcids is a button, you might put this sort of code in its Action event to show some number as the caption of that button.

Dim mark As Integer mark = 25 + 30 Me.Caption = Str(mark)

Oh, sorry for that. ScoreAminoAcids would be a label that should display the score, which is the mark integer, once the Submit button is clicked.

A label has a Text property (not a Caption), which is a string. Str() converts an integer to a string representation. So you want

ScoreAminoAcids.Text = Str(mark)

As for Radio Buttons: they are grouped by Parent. Put each group of radio buttons on a separate parent control - a groupbox, canvas, pagepanel, rectangle, whatever. Then they will operate independent of each other.

Okay,

after playing with the program, I decided to put my quiz in a page panel. However, I’m having a harder time with scoring.

Anyway, can anyone show me how a sample code of how to make a score code when a page panel is used? It’s kind of a new idea for me to use one so I have no clue how to code it.

For example, radio buttons are the choices, and we are using 2 questions of true or false. If both questions are true, how do I score this?

What’s wrong with the code you posted above? The presence of a pagepanel shouldn’t change anything.

Super thanks, @Tim Hare! I figured it out! Yaaay!