I'm working in Visual Basic 2010 Express
I want to disable all checkbox of a Form
Not only that, as you can see in the code, there are 49 checkbox. And everyone has an event, I want to save code and optimize it.
Public Class Form1
Dim intNumber As Integer
Dim arrNumber(0 To 5) As Integer
Dim i, x, y As Integer
Dim maxCheck = 6
Dim count As Integer = 1
Private Sub setCheckbox(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox9.Click, CheckBox8.Click, CheckBox7.Click, CheckBox6.Click, CheckBox5.Click, CheckBox49.Click, CheckBox48.Click, CheckBox47.Click, CheckBox46.Click, CheckBox45.Click, CheckBox44.Click, CheckBox43.Click, CheckBox42.Click, CheckBox41.Click, CheckBox40.Click, CheckBox4.Click, CheckBox39.Click, CheckBox38.Click, CheckBox37.Click, CheckBox36.Click, CheckBox35.Click, CheckBox34.Click, CheckBox33.Click, CheckBox32.Click, CheckBox31.Click, CheckBox30.Click, CheckBox3.Click, CheckBox29.Click, CheckBox28.Click, CheckBox27.Click, CheckBox26.Click, CheckBox25.Click, CheckBox24.Click, CheckBox23.Click, CheckBox22.Click, CheckBox21.Click, CheckBox20.Click, CheckBox2.Click, CheckBox19.Click, CheckBox18.Click, CheckBox17.Click, CheckBox16.Click, CheckBox15.Click, CheckBox14.Click, CheckBox13.Click, CheckBox12.Click, CheckBox11.Click, CheckBox10.Click, CheckBox1.Click
If count < 6 Then
count = count + 1
Else
End If
End Sub
End Class
Aucun commentaire:
Enregistrer un commentaire