NoodleCollie
NoodleCollie

Reputation: 1087

Turning off VBA editor auto-format of code lines

I'm trying to accomplish a Debug.Print without a newline in Access 2007, as in http://www.vbforums.com/showthread.php?581952-RESOLVED-debug-print-with-no-newline

Debug.Print --no-newline ".";

However, the auto-syntax checker converts this when I move to a different line of code to:

Debug.Print --no - newline; ".";

I have tried turning off Options -> Auto Syntax Check but the problem still persists. Is there any way to fix this?

Upvotes: 2

Views: 899

Answers (1)

HansUp
HansUp

Reputation: 97101

Debug.Print does not have an option named --no-newline. So when the VB Editor encounters the line you tried, it (incorrectly) guesses you want a subtraction and adjusts the code line based on that guess.

The unquoted semicolon after the text you want to Debug.Print is what actually suppresses the new line. Consider this procedure ...

Public Sub PrintWithoutNewline()
    Debug.Print "A";
    Debug.Print "B";
End Sub

Calling that procedure in the Immediate window prints "AB" on one line, and leaves the insertion point (cursor) at the end of that line instead of at the start of a new line.

PrintWithoutNewline
AB

Upvotes: 3

Related Questions