Common routine to handle a check box

  • Thread starter Thread starter Mike News
  • Start date Start date
M

Mike News

I have a checkbox on a userform, and in a procedure I want to

make the checkbox invisible and
set it to false

Sub blob(x As CheckBox)
x.Visible = False
x = False
End Sub

So I have the above routine, but when am I calling it, how do I call
blob
blob(checkbox1) doesn't work because it's pass the value in I think
which is a boolean, and not of type checkbox
 
Here is an example

Private Sub CommandButton1_Click()
blob Me.CheckBox1
End Sub

Private Sub blob(cb As MSForms.CheckBox)
MsgBox cb.Name
End Sub

This passes the object, not just one property, so you can access those
properties from within blob.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Here is an example

Private Sub CommandButton1_Click()
blob Me.CheckBox1
End Sub

Private Sub blob(cb As MSForms.CheckBox)
MsgBox cb.Name
End Sub

This passes the object, not just one property, so you can access those
properties from within blob.
Thanks. I'd read about using Me from within the event on a checkbox,
but thought that referred to the object and not the whole userform

Many thanks
 
Me generally refers to the containing object, so it is the Userform in
userform code module, the worksheet in that sheet code module, and the
workbook in ThisWorkbook.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top