Aaron Warnke
Aaron Warnke

Reputation: 213

How to get values of multiple checkboxes in VB.Net?

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?

Upvotes: 0

Views: 6598

Answers (1)

Donny McCoy
Donny McCoy

Reputation: 130

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

Upvotes: 3

Related Questions