Optamis
asked on
Writing to a text file
This might be an easy question but I'm having problems writing to a text file in visual basic .net 2005. The old visual basic syntax of " Open "file" for output as #1" does not seem to work at all. This is not really the problem though, my problem lies in just getting the syntax right to write to a simple text file created using:
Dim result As System.IO.TextWriter = System.IO.File.CreateText( "C:\Docume nts and Settings\astairs\Desktop\r esult.txt" )
Any help is greatly appreciated!!
Dim result As System.IO.TextWriter = System.IO.File.CreateText(
Any help is greatly appreciated!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I believe the following would all give you results for new line:
Chr(13) + Chr(10)
file.WriteLine()
ChrW(13) + ChrW(10)
Environment.NewLine()
I do not know exactly what you mean by a new page though.
Chr(13) + Chr(10)
file.WriteLine()
ChrW(13) + ChrW(10)
Environment.NewLine()
I do not know exactly what you mean by a new page though.
Also, in the future, you may be better off posting your questions here:
https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/
https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/
ASKER
Thanks List244, Unfortunatly
Chr(13) + Chr(10)
file.WriteLine()
ChrW(13) + ChrW(10)
Environment.NewLine()
isn't working for me to get a new line. All I need to do is after the Writeline is start a newline. Also, what I mean but a new page is that after so many writes or when the page is full it will insert the page number and start a new page. Any ideas?
Thanks again!!
Chr(13) + Chr(10)
file.WriteLine()
ChrW(13) + ChrW(10)
Environment.NewLine()
isn't working for me to get a new line. All I need to do is after the Writeline is start a newline. Also, what I mean but a new page is that after so many writes or when the page is full it will insert the page number and start a new page. Any ideas?
Thanks again!!
ASKER
I figured it all out, thanks for the help. Without your guidance I wouldn't have the working writelines. Thanks List244.
Optamis, I should have been more clear with my first post, what I meant was you could use the chr and environment options
as string appends to add new lines. The file.WriteLine() would write a line byitself. They were just many options on how
you could do it.
However, I am glad you got it all worked out.
as string appends to add new lines. The file.WriteLine() would write a line byitself. They were just many options on how
you could do it.
However, I am glad you got it all worked out.
ASKER