VBA:Debug.Print 没有换行符?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20749369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 01:04:17  来源:igfitidea点击:

VBA: Debug.Print without newline?

vbadebuggingnewline

提问by armstrhb

For debugging in VBA, I have several Debug.Printstatements throughout my code. For a line-parsing block, I'd like to print the line, and output any flags inlinewith the line, without having multiple Debug.Print sFlag & sLinestatements throughout the many if/elseif/else blocks.

为了在 VBA 中进行调试,Debug.Print我的代码中有几条语句。对于行解析块,我想打印该行,并输出与该行内联的任何标志,而无需Debug.Print sFlag & sLine在许多 if/elseif/else 块中包含多个语句。

Is there a way, within VBA, to suppress the newline at the end of a Debug.Printstatement?

在 VBA 中,有没有办法抑制Debug.Print语句末尾的换行符?

回答by armstrhb

It turns out you can easily do this by simply adding a semicolon to the end of your Debug.Printstatement. Like so:

事实证明,您只需在Debug.Print语句末尾添加分号即可轻松完成此操作。像这样:

While oExec.StdOut.AtEndOfStream = False
   sLine = oExec.StdOut.ReadLine
   If bInFileSystem Then
      If AnalyzeFileSystemLine(sLine) = False Then
         Debug.Print "[FSERR]: ";
      End If
   ElseIf bInWASCheck Then
      If AnalyzeWASLine(sLine) = False Then
         Debug.Print "[WASERR]: ";
      End If
   End If

   Debug.Print sLine
Wend

So, some sample output will be:

因此,一些示例输出将是:

test text things look good!
[FSERR]: uh oh this file system is at 90% capacity!
some more good looking text :)
[WASERR]: oh no an app server is down!