Trying to start a second line ( ie use of enter key) in an output file


S

Susan Hayes

Hello

I am trying to write to a file but cannot use the enter key to start a new line. I have tried char(10) and it puts a
square box. I tried every chr in a loop and the output file has no characters on the second line, therfore no enter
key. I have also tried vbkeyreturn and does nothing.

Anyone know how to work around this little problem?

Heres my code ( its been simplyfied)

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "c:\cd.asc" 'Create a file
Set f = fs.GetFile("c:\cd.asc")
Set ts = f.OpenAsTextStream(ForWriting, TristateFalse)
ts.write "hello"
ts.write Chr(10)
ts.write "hello"
ts.Close

Thanks in advance

Mike
 
Ad

Advertisements

B

Bob Phillips

Use vbCrLf

--

HTH

RP
(remove nothere from the email address if mailing direct)


Susan Hayes said:
Hello

I am trying to write to a file but cannot use the enter key to start a new
line. I have tried char(10) and it puts a
square box. I tried every chr in a loop and the output file has no
characters on the second line, therfore no enter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top