简体   繁体   English

运行窗体时的Powershell输出问题

[英]Powershell Output Question when running Forms

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]) . 当我运行Forms代码时,我有添加到Form中的不同对象(按钮,标签等),我通过使用命令$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 当我单击“提交”按钮后,字符串“ OK”被添加到上面显示的数字中

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

Some actions like .Add() are producing output. 诸如.Add()类的某些操作正在产生输出。 To prevent this, pipe the output into the [void] by adding | Out-Null 为了防止这种情况,请通过添加| Out-Null将输出通过管道传递到[void] | Out-Null at the end of the line or [void] directly infront of the variable that is used, like: 在行尾或在所使用变量的正前方[void]处为| Out-Null ,例如:

$foo.SomethingThatGeneratesOutput() | Out-Null

or 要么

[void]$foo = SomethingThatGeneratesOutput

As T-Me has stated, to prevent output being generated when executing methods as you are use [Void]. 正如T-Me所说,为防止在执行[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). 如果您的代码仍在返回不需要的数据,请在PowerShell ISE中打开脚本,然后逐行执行脚本(选择该行,然后按F8键)。 This will help you determine which line of code is generating output still. 这将帮助您确定哪一行代码仍在生成输出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行powershell命令时无输出 - No output when running powershell command 在循环中运行Powershell命令时输出被截断 - Truncated output when running Powershell command in a loop Powershell脚本未运行或给出和输出 - Powershell script not running or giving and output Powershell在网络位置上计数文件,运行Powershell与ISE时输出不同 - Powershell counting files on network location, different output when running Powershell vs the ISE Powershell 在控制台和 ISE 中形成应用程序不同的输出 - Powershell forms application different output in console and ISE Powershell:在Invoke-Command脚本块中运行Start-Process时,没有输出到控制台 - Powershell: No output to console when running Start-Process in an Invoke-Command scriptblock 在 powershell 中运行命令时,如何为 stdout/stderr 上的所有输出添加日期/时间? - When running a command in powershell how can I prepend a date/time for all output on stdout/stderr? 为什么在 PowerShell 中运行时“where”命令不显示任何输出? - Why doesn't the 'where' command display any output when running in PowerShell? 在Powershell中远程运行stopservice命令时如何重定向或隐藏系统参数的输出 - How do i redirect or hide the output of the system parameters when running a stopservice command remotely in powershell 为什么在一行中运行两个 PowerShell 命令时输出格式会发生变化? - Why is the output format changed when running two PowerShell commands in one line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM