I am trying to fix up the code below which I tried to follow from the MSDN Library.
The problem I face is this: The code below DOES create the text file Test2.txt, it does print hello and goodbye but it prints it like this:
h e l l o g o o d b y e <--------- spaced out and all on same line
What I want to do is print it like this:
hello
<carriage return>
goodbye
I have tried inserting Chr(10) , Chr(13) but all that does is insert a box character into the text file. I have also tried vbCrLf and that did nothing either.
What do I need to fix to get the text to display properly?
Module1 contains the declaration:
Imports
System.IO
Imports
System.Text
Form1 contains the code:
Dim objStreamWriter As IO.StreamWriter
'Open the file.
objStreamWriter =
New IO.StreamWriter("C:\Test2.txt", True, System.Text.UnicodeEncoding.Unicode)
'Write out text
objStreamWriter.Write("hello")
objStreamWriter.Write("goodbye")
'Close the file.
objStreamWriter.Close()
End Sub
Enter your message below
Sign in or Join us (it's free).