I have a form with a lot of text boxes and an equal number of check boxes. I want the check box to be disabled if the text in the text box is a certain value. I'm still a VB noob, so forgive me if my question is too trivial.
Obviously this doesn't work, otherwise I wouldn't be asking, but by looking at this you should be able to see what I am trying to do. Does anyone have a solution or suggestion?
The error is....
Unable to cast object of type 'System.String' to type System.Windows. Forms.Control'.
Now I know I can't refer to a control using the string combination, but thats all I could think of to get through all of my controls in a for..next.
Thanks
Obviously this doesn't work, otherwise I wouldn't be asking, but by looking at this you should be able to see what I am trying to do. Does anyone have a solution or suggestion?
Code:
Dim x Dim y As New Control Dim z As New Control For x = 1 To 40 y = "txtTextBox" & x z = "chkcheckBox" & x If y.Text = "3" Then z.Enabled = False End If Next
Unable to cast object of type 'System.String' to type System.Windows. Forms.Control'.
Now I know I can't refer to a control using the string combination, but thats all I could think of to get through all of my controls in a for..next.
Thanks
Comment