0

When I run my Forms code I have different objects that are added to the Form (buttons, labels, etc) I attache the objects to the form by using the command $Form1.Controls.Add([ObjectType]).

My question is, when I run my code I get an instant sequence of numbers in my console and output dialogue box of:

0 1 2 3 4 5 6 7 8 9 0 1 2

When after I click Submit button the string "OK" is added to the numbers shown above

0 1 2 3 4 5 6 7 8 9 0 1 2 OK

Why is this happening and how can I remove these or atleast omit them from displaying. The OK displays once the Submit button is pressed. OK

1
  • 1
    I don't see a single ? in your "Question".. please edit the question and try to make clearer what your problem is. Take a look at How to Ask and try to offer an minimal reproducible example. Also take a look at tour. Commented Jan 23, 2019 at 7:54

2 Answers 2

1

Some actions like .Add() are producing output. To prevent this, pipe the output into the [void] by adding | Out-Null at the end of the line or [void] directly infront of the variable that is used, like:

$foo.SomethingThatGeneratesOutput() | Out-Null

or

[void]$foo = SomethingThatGeneratesOutput
Sign up to request clarification or add additional context in comments.

3 Comments

For more specific help we need to see more of your code.
I did try that and it did not work the numerical values are still displaying and I believe they have something to do with the objects (Buttons, labels, etc) when added.
There are to much possible reasons why this shows up. Without some code snipets there is no way to tell whats causing that.
0

As T-Me has stated, to prevent output being generated when executing methods as you are use [Void].

[Void]$Form1.Controls.Add([ObjectType])

If your code is still returning unwanted data, open the script in PowerShell ISE, and execute the script line by line (select the line and press F8). This will help you determine which line of code is generating output still.

1 Comment

Was able to try this and thank you it did work perfect. Thank you all for the help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.