title: Iterating over several GUI elements
body: <p>I have a GUI based form with a series of fields on it and want to update the corresponding label when text is entered into one field.  I've been able to get it to work using the following code</p>
  
  <pre><code>$objTextBoxRD1.add_keyup({$objLabelLU1.Text = Get-Date})
  $objTextBoxRD2.add_keyup({$objLabelLU2.Text = Get-Date})
  $objTextBoxRD3.add_keyup({$objLabelLU3.Text = Get-Date})
  $objTextBoxRD4.add_keyup({$objLabelLU4.Text = Get-Date})
  </code></pre>
  
  <p>Is there a more elegant way to achieve the same result?</p>
  
  <p>I tried the following but when I enter text into any <code>$objTextBoxRD</code> fields it only updates <code>$objLabelU4</code>.</p>
  
  <pre><code>$Count = 1
  foreach ($User in $ISDept) {
      $objTextBoxRD = Get-Variable -Name ('objTextBoxRD' + ([string]$Count)) | Select -Expand Value
      $objLabelLU = Get-Variable -Name ('objLabelLU' + ([string]$Count)) | Select -Expand Value
  
      $objTextBoxRD.add_keyup({$objLabelLU.Text = Get-Date})
      $Count++
  }
  </code></pre>
  
  <p>The <code>$objTextBoxRD</code> and <code>$objLabelLU</code> variables have been generated from arrays and would like to automate this section as the number of variables that get created can vary.</p>