Checkboxes and select case Statements

ARC

Well-known member
Joined
Sep 9, 2006
Messages
63
Location
Minnesota
Programming Experience
Beginner
When i test it, it just quits when I 'check' b1. anyone know why?

Err.. when the user checks box 1, i want it to toggle b2 and b6 from whatever their current state is; checked or unchecked.

VB.NET:
Public Class Form1
Private Sub b1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.CheckedChanged
 
Select Case b2.Checked
    Case False
        Me.b2.Checked = True
    Case True
        Me.b2.Checked = False
End Select
 
Select Case b6.Checked
    Case False
        Me.b6.Checked = True
    Case True
        Me.b6.Checked = False
End Select
 
End Sub
 
VB.NET:
Private Sub b1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.CheckedChanged
    Me.b2.Checked = Not Me.b2.Checked
    Me.b6.Checked = Not Me.b6.Checked
End Sub
 
Awesome, thanks! If it's not too much trouble, could you (or anyone) explain why that first way didnt work? I see how yours works, but I dont understand why the first way doesnt. No biggy I guess, just curious :)
 
The code you posted works correctly, the code JohnH show is more compact and quick.

You say it just quits when I 'check' b1. What does that mean? If you get errors it always best to post them. You can also debug and step through the code to see where the error occurs.
 
Back
Top