How do I print/display a block of text with newlines?

So I just want to display all the available Services in a neat and tidy fashion. MsgBox and Print both gobble newline and give me a huge blob of text…

REM  *****  BASIC  *****
Option Explicit

Sub Main
Dim x, i
Dim s As String: s = ""
x = GetProcessServiceManager().getAvailableServiceNames()

For i = LBound(x) To UBound(x)
	s = x(i) & s & CHR$(10)
	Next

Print(s)
End Sub

Nothing “gobbled” here.
You simply append all the line breaks at the end of your string s.
In addition you put the latest (highest index) service name in the first place.

Use

Sub Main
Dim x, i
Dim s As String
x = GetProcessServiceManager().getAvailableServiceNames()
s = ""
For i = LBound(x) To UBound(x)
    s = s & IIf(s="", "", Chr(10)) & format(i, "0000") & ": " & x(i) 
Next i

MsgBox(s)
End Sub  

but dont expect to see all the 1006 lines. The output will be clipped.

[oh nm, Print is line by line MsgBox is multiline] I don’t understand how that works but my example doesn’t. Why doesn’t Print “a” & “b” & CHR(10) display the \n?

“a” & “b” & CHR(10)

it becomes “ab\n”

Now consider this:

s = ""
for i = 0 to 5
    s = i & s & CHR(10)
next i

i = 0 => s = “0” & “” & CHR(10) => 0\n

i = 1 => s = “1” & “0\n” & CHR(10) => 10\n\n

i = 2 => s = “2” & “10\n\n” & CHR(10) => 210\n\n\n

All newlines get appended to the end.

You likely want s = i & CHR(10) & s instead of s = i & s & CHR(10) if you want to prepend, and what @Lupp suggested for append.