在VBA中进行调试,我在代码中有几个Debug.Print
语句。对于一段行解析的块,我想要打印该行,并将任何标志与该行内联输出,而不必在许多if/elseif/else块中使用多个Debug.Print sFlag & sLine
语句。
是否有一种方法可以在Debug.Print
语句末尾抑制换行符,只能使用VBA实现呢?
事实证明,你只需在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
所以,一些示例输出将是:
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!
Debug.Print
放在最底部,在Wend
下面。然后使用分号关闭Wend
上面的行。同样的结果。 - Smandoli