Semicolon in a Debug.Print Statement

I had no idea this existed.

Sub testsemicolon()

Dim i As Long

For i = 1 To 5
Debug.Print i
Next i

For i = 1 To 5
Debug.Print i;
Next i

End Sub

It’s right there in the help for the Print # Statement, but I’ve never paid attention to it.

13 thoughts on “Semicolon in a Debug.Print Statement

  1. Interesting. I frequently write text to ASCII files and this could be handy. Although I do like format control one has by building a text string and printing the single item to a line.

  2. It’s been part of BASIC’s PRINT statement since the original version at Dartmouth College in the mid 1960s.

  3. I’m not sure how I’ll use this, but I’m definitely pleased to have learned it. Thanks!

  4. The comma works too.

    If you are using it, it’s good practice to follow the loop with a simple Debug.Print…

    Mpemba

  5. @Mpemba –

    Yes, commas work too, just as the origial BASIC manual from 1965 says they do. Cudos to MSFT for not changing this, er, basic functionality.

  6. I used them as a schoolboy in the mid 70s when I started programming in BASIC; and in recent years in VBA.

  7. I am guessing that you never used the Tab or Spc functions then. I am pretty sure suppressing the newline by using a semi-colon was originally introduced (oh so many years ago now) so that one could chain together data along with the crude formatting capabilities offered by the Tab and Spc functions when printing to a file.

  8. QBASIC had PRINT USING, and I believe I recall BASICA did too, but I don’t believe VBA ever did. PRINT USING was what one used to format printed output in the dark ages of BASIC.

    Quibble: VBA’s print zones are 14 chars while original DTSS BASIC print zones were 15 chars.

  9. As others haves stated, this has been part of BASIC. So I’m just shocked people are discovering this now. ;-)


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.