VB.Net: Changing control properties from outside the form

I sometimes need to set a form's control properties from elsewhere in the code, and I'm getting strange errors whenever I try.   In my situation, I've created a checkbox that I want to change, but while running from withing another form.  Here's a sample of that code:

Dim UseCheck As System.Windows.Forms.CheckBox = MyForm.MyCheckbox
With UseCheck
    .Checked = False
    .Enabled = True
End With

Open in new window

With this code in place, the form won't open.
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
make sure the Modifiers property of your control is set to Public
PeterFrbAuthor Commented:
Yes, thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.