title: VB.NET For each exception on custom controls
body: <p>in VB.NET i have 2 custom controls, one is a TextBox and second one is a ComboBox.
  These have custom values like Bool _IsHidden and are added on runtime to a form.</p>
  
  <p>Now, at some point in the code I want to check if the _IsHidden is set to True or False and display that information. Since the user can edit this values when creating the control these are not set on creation.</p>
  
  <p>So what I tried is:</p>
  
  <p>(all of this is on MDI Forms)</p>
  
  <pre><code>For Each frm as CustomForm in Main.MdiChildren
  If frm.MyName = calledBy Then 'this part is just to know which form called the form to create the object
  For Each cntrl as CustomTextBox in frm.Controls
  'DO Something
  Next
  End if
  Next
  </code></pre>
  
  <p>Now.. if the first control is a custom ComboBox it thorws an error since it sees that it does not match the custom TextBox control.. </p>
  
  <p>how do i get around this? By my understanding it should just go through all of the controls on the said form and just check those who match CustomTextBox control ?</p>
  
  <p>Thank you</p>