Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting rid of CR character

Status
Not open for further replies.

sicohne

Technical User
Jun 30, 2003
51
GB
I am trying to export the value of some fields to a text file. I need each value to start on a new line. I am using the following code:
-----------------------
textbox1.text = textbox2.text & chr(13) & textbox3.text & chr(13).....
FileOpen(1,"c:\test.txt",OpenMode.Output)
Print(1,textbox1.text)
FileClose(1)
-----------------------

On opening the text file the information looks like this:
--------------
abc........
--------------

How do I get it to save as:
a
b
c
.......
 
Maybe add the line feed character?
Code:
textbox1.text = textbox2.text & chr(13) & chr(10) & textbox3.text & chr(13) & chr(10).....

Hope this helps

alternatively, use a StreamWriter
I dont have an example to hand in VB, but here's a C# example:
Code:
			StreamWriter sw = new StreamWriter(@"C:\Test.txt",false,Encoding.ASCII);
			for(int i=0; i < 10; i++)
			{
				sw.WriteLine(i)
                         }
			sw.Close();
 
the line feed character does the same thing. I'll try the StreamWriter thing and let you know.
The file has to be opened using Notepad by the way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top