For debugging in VBA, I have several Debug.Print
statements throughout my code. For a line-parsing block, I'd like to print the line, and output any flags inline with the line, without having multiple Debug.Print sFlag & sLine
statements throughout the many if/elseif/else blocks.
Is there a way, within VBA, to suppress the newline at the end of a Debug.Print
statement?
vbNewLine inserts a newline character that enters a new line. In the below line of code, you have two strings combined by using it. Range("A1") = "Line1" & vbNewLine & "Line2" When you run this macro, it returns the string in two lines. It returns the character 13 and 10 (Chr(13) + Chr(10)).
To break a single statement into multiple linesUse the line-continuation character, which is an underscore ( _ ), at the point at which you want the line to break.
It turns out you can easily do this by simply adding a semicolon to the end of your Debug.Print
statement. Like so:
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With