What are the rules for counting bytes in the immediate window? I have found very little in the way of VBA docuimentation to try and help with this, because is seems to be a relatively uncommon golfing language. For clarity, I'm not sure how the rules would be applied in a few test cases below, and would like an explanation of how to count the bytes for these VBA specific examples

If I type into the immediate window, several things are returned, I want to know the byte count of what is returned (prompted by my answer to this question). Here's some specific cases I'm not sure about:


When I enter this, I am put on a new line. Pressing down arrow does nothing, so I assume no bytes are below the cursor. I notice that a space is added after the ;, so I'm guessing the byte count is 1 for the space + 1 for the newline? Or is it customary to not count the extra space?



That evaluates the constant a, undefined at this point. When entered, the cursor is put 2 lines below the input, rather than immediately below as before. Also, a space is put after the a, and on the intermediate line. So that suggests 2 newlines and 2 spaces = 4 byte output. Also, unlike before, pressing does do something, it takes me onto the next line. So maybe 3 newlines?



I have no idea what's going on there, does it count as a tab or a load of spaces? Maybe I'm mixing up newlines and spaces, I'm not sure.

  • \$\begingroup\$ What are you trying to count and why? Normally we care about counting the bytes in your code, for scoring purposes, so I can't understand why you're worried about how many bytes of output you're getting. \$\endgroup\$ May 18, 2017 at 15:09
  • \$\begingroup\$ @PeterTaylor sometimes output size matters: codegolf.stackexchange.com/questions/121056/… \$\endgroup\$
    – steenbergh
    May 18, 2017 at 15:10

1 Answer 1


?; doesn't add a space to the end of the line. When you select all text in the immediate window, it visualises the line-break by adding a bit of space to the end, but it isn't an actual space. Try moving the caret there. The command ?; means PRINT (nothing) and suppress tabs and newlines. Newlines are added automatically by VBA to print statements, except when suppressed with ;. This statement therefore has an output of 0 bytes.

?, means PRINT (nothing), then TAB and print (nothing again). Since newlines are not suppressed, that is also added. In my command window, it seems to add 14 spaces instead of a single tab. I find it hard to score this... I'd go for 2 bytes: tab and newline.

?a says Print the undefined var a (nothing) and is again followed by a newline. Output 1 byte.

The cursor is moved to either 1 or 2 lines below the statement (depending on newlines being allowed or suppressed) simply to allow you to type the next statement and should not be considered as output.

  • \$\begingroup\$ I'm not convineced on the first one, purely because the 'space' can be selected, pressing ctrl+a and pasting into a byte counter gives 3 not 2 \$\endgroup\$
    – Greedo
    May 18, 2017 at 14:12
  • \$\begingroup\$ Yes, it's 3 bytes: question mark, semicolon, newline. Maybe there's a difference in version of the console. I'm using Excel 2010. \$\endgroup\$
    – steenbergh
    May 18, 2017 at 14:16
  • 1
    \$\begingroup\$ I also can't move the caret over it, but can select it. So to double check, you would say the output of ?; is 1 byte, or still 0 like in your answer since the program doesn't add the extra character, VBA does? \$\endgroup\$
    – Greedo
    May 18, 2017 at 14:22
  • 2
    \$\begingroup\$ Output is 0 bytes. You add the newline by pushing enter - that also executes the code. The code itself does utterly nothing. \$\endgroup\$
    – steenbergh
    May 18, 2017 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .