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
 
Back
Top