title: Adding text to label from variable
body: <p>Take this code, the function is using vsphere cmd-let to retrieve CPU number based on a selected VM from a list box. The output was working into another list box but I want to be able to output the result to a label</p>
  
  <pre><code>function fill_updatelistbox 
  {
  $vmlist1 = Get-vm -Name $listBox1.SelectedItem | select NumCPU
  foreach ($vm1 in $vmlist1)
  {
  $label1.Text($vm1.NumCPU)
  }
  }
  
  
  $label1.DataBindings.DefaultDataSourceUpdateMode = 0
  $System_Drawing_Point = New-Object System.Drawing.Point
  $System_Drawing_Point.X = 400
  $System_Drawing_Point.Y = 115
  $label1.Location = $System_Drawing_Point
  $label1.Name = "label1"
  $System_Drawing_Size = New-Object System.Drawing.Size
  $System_Drawing_Size.Height = 23
  $System_Drawing_Size.Width = 100
  $label1.Size = $System_Drawing_Size
  $label1.TabIndex = 0
  $label1.Text = ""
  </code></pre>
  
  <p>Edited: The below code worked using a listbox</p>
  
  <pre><code>function fill_updatelistbox
  {
  $vmlist1 = Get-vm -Name $listBox1.SelectedItem | select NumCPU
  foreach ($vm1 in $vmlist1)
  {
  [void]$listBox2.Items.Add($vm1.NumCPU)
  }
  }
  
  $tabPage2.Controls.Add($panel2)
  $listBox2.DataBindings.DefaultDataSourceUpdateMode = 0
  $listBox2.FormattingEnabled = $True
  $System_Drawing_Point = New-Object System.Drawing.Point
  $System_Drawing_Point.X = 1
  $System_Drawing_Point.Y = 1
  $listBox2.Location = $System_Drawing_Point
  $listBox2.Name = "listBox2"
  $System_Drawing_Size = New-Object System.Drawing.Size
  $System_Drawing_Size.Height = 369
  $System_Drawing_Size.Width = 160
  $listBox2.Size = $System_Drawing_Size
  $listBox2.TabIndex = 0
  $panel2.Controls.Add
  </code></pre>