title: using a string variable to control a textbox property
body: <p>I have various textboxes on a form to enter numbers and want to have a single function which can check the entry and highight the box in red if incorrect rather than repeating the same code for each textbox.</p>
  
  <p>Is it possible to set the name of the textbox (_FreqTextBox) as a variable so I can make this a generic function for each textbox. An example function is below. I've tried to find examples of this but no luck so far. Newish to Python so apologies if this is obvious.</p>
  
  <pre><code>def FreqTextBoxTextChanged(self, sender, e):
      self._FreqTextBox.BackColor = System.Drawing.SystemColors.Window
      IsNumber,text_value = self.CheckNumber(self._FreqTextBox.Text)
      if (IsNumber == False):
          self._FreqTextBox.BackColor = System.Drawing.Color.Red
          return
      IsNumber = self.NegativeValueMsg(text_value)
      if (IsNumber == True):
          self._FreqTextBox.BackColor = System.Drawing.Color.Red
      return
  </code></pre>