Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Function returns numbers before desired values

$
0
0

Hi everyone,

So I have a powershell GUI script where the users input stuff, there is a textbox and 9 comboboxes.

Everything works fine, I call the function this way:

$return myFunction $param1 $param2 $param3 ...

Then, in my function, I return all the values from the textbox and 9 comboboxes this way:

return myTextBox.Text, myComboBox1.SelectedItem, myComboBox2.SelectedItem ...

Now when I want to use the values in my $return table, I'd do this:

"Value of textbox: " +$return[0]

"Value of combobox1: " +$return[1]

...

Now this is where my problem begins...

The number of values in the comboboxes are ALL added to my $return variable.

For instance, let's say my first combo box had 5 choices, my $return variable will look something like this if i simply show it on screen:

0
1
2
3
4

It does that for EVERY combo box, if the second one had 3 choices it would then add: 0,1,2 to the next values of my $return variable. And only AFTER these numbers do the real values selected by the user show. A little something like this:

0
1
2
4
0
1
0
1
2
0
1
2
3
James
Neal
Washington
True
Yes
November

So to use the first value selected by the user I have to use $return[13] instead of $return[0] since there are so many numbers there.

So I have two questions, I'd like to know why it's doing this and how can I manage to remove these values and only have the ones the user has selected in my $return variable.

I hope I'm being clear!

Thank you! Smile

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles