Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9101279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:05:20+00:00 2026-06-17T01:05:20+00:00

Take this code, the function is using vsphere cmd-let to retrieve CPU number based

  • 0

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

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 = ""

Edited: The below code worked using a listbox

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:05:21+00:00Added an answer on June 17, 2026 at 1:05 am

    FYI, I don’t have the resources to test this, but I’ll try to help. First, make sure the listbox is single-choice, because label is more of a single-item textbox 🙂 Then you can try:

    function fill_updatelistbox 
    {
    #Should return a single VirtualMachine object
    $vm = Get-vm -Name ($listBox1.SelectedItem.toString())
    $label1.Text = $vm.NumCPU.toString()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

take a look at this code: $(document).ready(function() { document.getElementById(sliderId).onmousedown = sliderMouseDown; }); function sliderMouseDown()
Take this example code (ignore it being horribly inefficient for the moment) let listToString
Take this example code private void test() { Label1.Text = Function 1 started.; function1();
i'm using this code to make simple encryption: function idEncrypt($string) { $multiply = 2457;
I want to check an array in a condition. Let's take this simple code
Take this code for example: (function(foo) { foo.init = function() {}; // other public/private
Take this code: using System; namespace OddThrow { class Program { static void Main(string[]
Hi I'm using this code to generate machine signature. But it's take noticeable time
If I take this code and compile it (advanced optimizations) /**@constructor*/ function MyObject() {
Take this code: var obj = { init: function(){ console.log(obj.count); //or console.log(this.count); }, count:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.