title: Find dynamically added control in VB .NET
body: <p>I've created a new tabpage and also added a richtextbox to it:</p>
  
  <pre><code>Private Sub AddTab(ByVal ctrl As TabControl, _
                                ByVal text As String)
      If Me.InvokeRequired Then
          Me.Invoke(New AddTabDelegate(AddressOf AddTab), _
                    New Object() {ctrl, text})
          Return
      End If
  
      Dim NewTab As New TabPage
      NewTab.Name = "OutputTab" &amp; outputs.Item(outputs.Count - 1)
      NewTab.Text = "Domain"
      Dim NewTextbox As New RichTextBox
      NewTextbox.Name = "OutputTextbox" &amp; outputs.Item(outputs.Count - 1)
  
      ctrl.Controls.Add(NewTab)
      NewTab.Controls.Add(NewTextbox)
  End Sub
  </code></pre>
  
  <p>Now I try to access the richtextbox somewhere else in the code:</p>
  
  <pre><code>Dim NewTextbox As RichTextBox
  NewTextbox = Me.Controls.Item("OutputTextbox" &amp; current_output)
  debug.print(NewTextbox.name)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>A first chance exception of type 'System.NullReferenceException' occurred in program.exe
  </code></pre>
  
  <p>I know the name is rigth cause I have printed the name in the create method and I have printed the name string in the code where I try to access it.</p>
  
  <p>So by the looks of it it seems <code>.Item()</code> is not the right way to access the control.</p>
  
  <p>So how to access to dynamically created control?</p>