0

Hi I have to create a groupbox with 6 checkboxes in it. When multiple checkboxes are clicked the checkbox with the higher int. value will be displayed in a label. How do I do this? How do I test the value of 6 checkboxes against the others and display the highest one that is checked? So if say checkbox1 is checked it will display a 1 in a label. So if multiple checkboxes are checked how can I just display the highest one?

0

1 Answer 1

3
Dim Chk As CheckBox
Dim i As Integer = 0

For Each Chk In GrpBox.Controls

    If TypeOf (Chk ) Is CheckBox Then
        If Chk .checked Then
            If Chk .Tag > i Then i = Chk .Tag
        End If
    End If
Next
Sign up to request clarification or add additional context in comments.

2 Comments

Ok where do I put that code then, in one of the checkbox subs? Or in the main class?
You can put it in the form_load event thought I suggest that a better practice is to put it in your button's click event. I presume you have button or something similar that the user clicks to generate an event; at which point you will need to evaluate your checkboxes. Let me know if you have a different scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.