Prevent multiple selection in a control of checkboxes

  1. 8 months ago

    I'm attempting create a quizz app.
    Created a new control of 4 checkboxes namely:

    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

    23 Jan 2019 Xojo Inc, Third Party Store

    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
  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?


  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

    24 Jan 2019 Pre-Release Testers Rochester, NY

    @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!