Prevent multiple selection in a control of checkboxes

  1. 4 weeks ago

    Hi,
    I'm attempting create a quizz app.
    Created a new control of 4 checkboxes namely:
    AnswerCheckBox(0)
    AnswerCheckBox(1)
    AnswerCheckBox(2)
    AnswerCheckBox(3)

    How do I write a code to allow the user to select only ONE of the 4 checkboxes?
    I think I need to use a loop to run through the controls but could not figure out how.

    Any pointers greatly appreciated.

  2. Paul L

    Jan 23 Xojo Inc http://docs.xojo.com

    You could use RadioButtons which would do this automatically.

    If you really want CheckBoxes, you could put code in the Action event to uncheck all the other CheckBoxes.

    Looks like you're using a Control Set, so something like this:

    For i As Integer = 0 To 3
      If i <> index Then
        AnswerCheckBox(i).Value = False
      End If
    Next
  3. Thank you very much.
    Will look into RadioButtons as well.

    Greatly Appreciated

  4. If I use a radiobutton control, how do I use loop to check which radiobutton was selected?

    Thanks,
    Benny

  5. Thank you very much!.
    Please ignore the last question regarding radiobutton. Figured that out!

  6. Please, what is the answer to this question?

    I think it was .index?

  7. Tim P

    Jan 24 Pre-Release Testers feedback://46303

    @Detlef K Please, what is the answer to this question?

    I think it was .index?

    You can name RadioButtons individually and check their Value property. You can also create a control array if that suits you, but I find that more difficult to maintain personally.

or Sign Up to reply!