[2005] Clear multiple Checkboxes with With End-With Statement
Hey guys
i have a small college project on the go, the lecturer insists that we must use a with end-with statement to clear 3 checkboxes inside a groupbox
i know how to change multiple properties of 1 object using with end-with, but im lost as to how i can change 1 property of multiple checkboxes using it?
anyone point me in the right direction?
Re: [2005] Clear multiple Checkboxes with With End-With Statement
this works
vb Code:
With Me.GroupBox1
For x As Integer = 1 To 3
DirectCast(.Controls("checkbox" & x), CheckBox).Checked = False
Next
End With
Re: [2005] Clear multiple Checkboxes with With End-With Statement
Just so you know, that is a stupid use for a With block. Your lecturer is presumably trying to make a point but you'd never actually use a With block in a situation like this. A With block does nothing for the app. It exists solely so you don't have to type as much. In Paul's code you end up typing more.