-
May 17th, 2009, 03:00 AM
#1
Thread Starter
Hyperactive Member
Save to file on new line?
How can I save text from a textbox onto a new line in a .txt file?
this is a one-line textbox and I don't want to have any line skips like this
line 1
line 2
line 3
line 4
Can anyone please explain how to do this?
-
May 17th, 2009, 03:15 AM
#2
Re: Save to file on new line?
I'm a bit confused because you say its a "one-line text box" but what you've posted shows multiple lines. Is the problem the empty line between line 3 and line 4 or the fact that each "line" appears on a separate line.
-
May 17th, 2009, 03:17 AM
#3
Fanatic Member
Re: Save to file on new line?
Originally Posted by CoBHC
How can I save text from a textbox onto a new line in a .txt file?
this is a one-line textbox and I don't want to have any line skips like this
line 1
line 2
line 3
line 4
what s your code to do that ? i think there are many way to do it . please extract your fragment code.
-
May 17th, 2009, 03:23 AM
#4
Thread Starter
Hyperactive Member
Re: Save to file on new line?
Originally Posted by keystone_paul
I'm a bit confused because you say its a "one-line text box" but what you've posted shows multiple lines. Is the problem the empty line between line 3 and line 4 or the fact that each "line" appears on a separate line.
Originally Posted by manhit45
what s your code to do that ? i think there are many way to do it . please extract your fragment code.
Sorry for me being confusing, what I mean is the textbox is not set to multi-line and I want to add the text from the textbox to a .txt file one line at a time so if I put "World" into the textbox and the .txt file already has its first line set to Hello, then it would look like this
Hello
World
It would at first look like this though:
Hello
So I hope I was less confusing this time, you see, I'm American, and I can sometimes be misleading.
And also, What I mean by no blank line like what I said in the OP, I don't want it to randomly skip the first line or any line after that.
-
May 17th, 2009, 03:32 AM
#5
Re: Save to file on new line?
Ah OK I follow you now.
How do you know when to write the line of text - are you trapping the enter key or do you have a button or something like that?
Personally I would declare an array (or List or collection) of strings, and whenever you get the message to add a new line, examine the contents of the textbox and only add it to your array if it is not blank (use trim to make sure that a line of just spaces would be ignored).
Then I'd write the file all at once when you know you are finished
-
May 17th, 2009, 02:29 PM
#6
Thread Starter
Hyperactive Member
Re: Save to file on new line?
Originally Posted by keystone_paul
Ah OK I follow you now.
How do you know when to write the line of text - are you trapping the enter key or do you have a button or something like that?
Personally I would declare an array (or List or collection) of strings, and whenever you get the message to add a new line, examine the contents of the textbox and only add it to your array if it is not blank (use trim to make sure that a line of just spaces would be ignored).
Then I'd write the file all at once when you know you are finished
I have a button. I just want a really basic file saver.
-
May 17th, 2009, 02:37 PM
#7
Re: Save to file on new line?
I assume that you already know how to write out to a text file as you were saying you just want it to stop putting in spaces?
If so then I've given you a workable answer above.
What bit do you not understand?
Last edited by keystone_paul; May 17th, 2009 at 02:41 PM.
-
May 17th, 2009, 03:26 PM
#8
Thread Starter
Hyperactive Member
Re: Save to file on new line?
Originally Posted by keystone_paul
I assume that you already know how to write out to a text file as you were saying you just want it to stop putting in spaces?
If so then I've given you a workable answer above.
What bit do you not understand?
Actually I don't know how to write to a text file, that's what I need to know, that spaces part was from when I used a textbox to make a list and at the top it had a space that I didn't want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|