title: VB.NET - How do i concatenate a Control name with another variable value to change it's properties?
body: <p>I want to change the properties (Example: ReadOnly, BorderStyle, Forecolor...) of the textbox referenced in &quot;with&quot;.</p>
  <pre><code>Private Sub Apply(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt10.KeyDown, txt0.KeyDown
  
     If txt10.ReadOnly = False Then
        If e.KeyCode = Keys.Enter Then
  
           With txt10
           .ForeColor = Color.White
           .ReadOnly = True
           .BorderStyle = BorderStyle.None
           End With
  
        End If
     End If
  End Sub
  </code></pre>
  <p>The thing is, I need to set these properties to a certain textbox, so I've declared a variable called &quot;Number&quot;, and I was thinking if this could work:</p>
  <pre><code>With Controls(&quot;txt&quot; &amp; Number)
           .ForeColor = Color.White
           .ReadOnly = True
           .BorderStyle = BorderStyle.None
           End With
  </code></pre>
  <p>This only works for some properties, and don't work with the &quot;with&quot;. Do you have any idea how to make this work?</p>