Hi
I have a set of Checkboxes each with a Textbox next it to. I have the following code, which is meant to loop through each CheckBoxe and if checked if gets the text contained in the textbox, these are linked through the tag of the checkbox, i have used it before and it worked fine but this time i am getting the following error:
Null Reference Exception was unhandled
Object reference not set to an instance of an object.
I have checked by simply getting get the tag and the value of the linked textbox and both are populating fine, but i don't want to have to manually write each link in IF Statements. The below code should take the Tag of the checked checkbox E.G txt1 if chk1 is checked and convert it into a TextBox so in the end it would be txtTest.Text = txt1.Text
Dim DisCheckBox As CheckBox() = {chk1, chk2, chk3, chk4, chk5}
For Each Chk In DisCheckBox
If Chk.CheckState = CheckState.Checked Then
txtTest.Text = CType(pnlChk.Controls(Chk.Tag.ToString()), TextBox).Text()
End If
Next
Like i said i have used this before but don't understand why i'm getting this error, any help would be very grateful.