>LParameters lEnable >With Thisform > .txtBox1.Enabled = lEnable > .txtBox2.Enabled = lEnable > .txtBox3.Enabled = !lEnable > .cmdDelete.Enabled = lEnable >Endwith > >I can call the method anywhere in the form say in the click event of a particular button: > >Thisform.ObjectEnable(.T.) - To enable the controls > >or > >Thisform.ObjectEnable(.F.) - To disable the controls >>I don't how to do it in VB?
Private Sub ObjectEnable(lEnable As Boolean) txtAddress1.Enabled = lEnable txtAddress2.Enabled = Not lEnable End SubNote you do not use thisform. Use nothing or "Me."
Dim loCtrl As TextBox For Each loCtrl In Me.Controls If TypeOf loCtrl Is TextBox Then loCtrl.Enabled = lEnable End If Next