title: Change properties of an unknown object in VB.NET
body: <p>I have a sub that handles when 14 ComboBoxes have their Index changed. I am able to cast the sender of the event, and obtain properties from there. However, after that, I want to be able to change the properties of the actual sender, rather than the cast one. How would I do this?</p>
  
  <p>Current code:</p>
  
  <pre><code>Private Sub ComboBoxIndexChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged, ComboBox2.SelectedIndexChanged [etc]
          Dim myComboBox As ComboBox = sender
  
          Select Case myComboBox.Text
              Case "Will"
                  Me.Controls(myComboBox.Name).Text = "555-555-555"
              Case "Bob"
                  Me.Controls(myComboBox.Name).Text = "555-124-1234"
              [etc]
          End Select
      End Sub
  End Class
  </code></pre>
  
  <p>As you can see, I am currently trying to use</p>
  
  <pre><code>Me.Controls(myComboBox.Name).Text
  </code></pre>
  
  <p>But I get the error: Object reference not set to an instance of an object.</p>
  
  <p>What can I do?</p>