Inserting line breaks in text file?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

I'm writing something similar to this into a text file:

txtfileError.WriteLine(CurrentDateTime(1) & " Error in Sub Sub1()" & idvar &
Chr(10) & Chr(13) & ex.Message)
txtfileError.WriteLine()

Instead of line breaks, I see two boxes. Everything runs together. There
is a double line break where the WriteLine() is. How do I place a single
line break in the text file?

Thanks,
Brett
 
Brett said:
I'm writing something similar to this into a text file:

txtfileError.WriteLine(CurrentDateTime(1) & " Error in Sub Sub1()" & idvar
& Chr(10) & Chr(13) & ex.Message)
txtfileError.WriteLine()

Instead of line breaks, I see two boxes. Everything runs together. There
is a double line break where the WriteLine() is. How do I place a single
line break in the text file?

'WriteLine' will add a single line break. Altneratively you can include
'ControlChars.NewLine' in the string you write to the file.
 
Chr(10) & Chr(13) should read Chr(13) & Chr(10)

The Carriage Return (13) comes before the Line Feed (10) vbCrLf

Even better use is to use Environment.NewLine or break it up into multiple
writes.

txtfileError.WriteLine(CurrentDateTime(1) & " Error in Sub Sub1()" & idvar)
txtfileError.WriteLine( ex.Message)
txtfileError.WriteLine()
 
Back
Top