views:

184

answers:

2

I have some strings I want to write to a file in VB6, I can write it fine but every time I do it adds a new line automatically after each write command.

Is there a function or a way to just write to the file without the automatic new line? Thanks.

A: 

You can use a semicolon after the Write command, for example:

Write #handle, "Hello";
Write #handle, "world";
Alex Warren
The output of this is `"Hello","world",`, which may not be desirable.
raven
Or on the other hand, it might - if you want to output a CSV for example. The OP says "it adds a new line automatically after each write command" so I assume that's what he was using in the first place.
Alex Warren
+5  A: 

The advice to use the semicolon is correct, but you most likely don't want to use it in conjunction with Write #, which will enclose your output in quotation marks. Use Print # instead.

Print #handle, "Hello";
Print #handle, " world";
Jim Mack
In addition to quotations marks, the Write statement adds commas when you use a semicolon in the output list. See my comment on Alex's answer: http://stackoverflow.com/questions/2543883/writing-to-file-vb6-without-new-line/2544022#2544022
raven