title: For each textbox loop
body: <p>I'm trying to make a foreach loop that checks every TextBox in a panel and changes BackColor if its Text is nothing. I've tried the following:</p>
  
  <pre><code>Dim c As TextBox
  For Each c In Panel1.Controls
    if c.Text = "" Then
      c.BackColor = Color.LightYellow
    End If
  Next
  </code></pre>
  
  <p>but I'm getting the error:</p>
  
  <blockquote>
    <p>Unable to cast object of type System.Windows.Forms.Label to type
    System.windows.forms.textbox</p>
  </blockquote>