Me.Controls CheckState

  • Thread starter Thread starter aarrgghh765
  • Start date Start date
A

aarrgghh765

Hi,

I'm using a counter to iterate through the CheckBox controls on my form
to set properties.

For i = 1 To 48
Me.Controls("X" & i.ToString).Enabled = False
Next

My question is; why can't I set the CheckState in this way like

For i = 1 To 48
Me.Controls("X" & i.ToString).CheckState =
CheckState.Checked
Next

Thanks.
 
Your application doesn't know what type of control it is looking at.
You need to do this:

For i = 1 To 48
CType(Me.Controls("X" & i.ToString), CheckBox).CheckState
= CheckState.Checked
Next
 
Thank you.

Your application doesn't know what type of control it is looking at.
You need to do this:

For i = 1 To 48
CType(Me.Controls("X" & i.ToString), CheckBox).CheckState
= CheckState.Checked
Next
 

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