VBA:调试。打印没有换行符?

标签 vba debugging newline

为了在 VBA 中进行调试,我的代码中有多个 Debug.Print 语句。对于行解析 block ,我想打印该行,并与该行一起输出任何标志 inline ,而无需在整个过程中使用多个 Debug.Print sFlag & sLine 语句许多 if/elseif/else block 。

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

最佳答案

事实证明,您只需在 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!

关于VBA:调试。打印没有换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20749369/

相关文章:

bash 参数用换行符替换

excel - 错误读取表字段所需的属性

ms-access - 以编程方式重命名 access 中的列

excel - 查找符合条件的第一个集合

iphone - 如何在 Xcode 4 中从断点操作打印字符串值?

android - 如何通过 TCP 使用 ADB 连接到 Android?

go - VS Code 去调试 : could not launch process: not an executable file

bash - 在带有换行符的 bash 中使用 cURL 的 Urlencode

vba - 如何超链接本地文件位置VBA

python - 如何删除列表列表中的 "\n"(python)