|
-
Sep 22nd, 2011, 03:43 AM
#1
Thread Starter
Member
Writing 4 or more strings to a single line in a text file
Hi everyone!
I've got my self in to a pickle here.
I'm trying to do something I used to do in basic? At-least I think you can do this in Basic, you know Qbasic, lol
What I'm trying to do is put 4-8 strings on to one line separated by a comma.
Example might be:
writer.writeline (bob1, bob2, bob3, bob4)
Out put might look like
Test, Test2, Test3, Test4
I'm tried looking in to formatting of writeline/write, but I didn't get any where with it.
Also if this is possible- I would like to be able to read it just like :
reader.readline (Rbob1, Rbob2, Rbob3, Rbob4)
If anyone cold just point me in the right direction, I'm sure I can figure it out - If not... Well I will ask another question.
Thanks,
Kyle
Last edited by Cpuboye11; Sep 22nd, 2011 at 03:44 AM.
Reason: Added Output example
-
Sep 22nd, 2011, 04:46 AM
#2
Re: Writing 4 or more strings to a single line in a text file
Are "writer" and "reader" file streams? Are you creating a console application or a windows forms application?
-
Sep 22nd, 2011, 05:05 AM
#3
Thread Starter
Member
Re: Writing 4 or more strings to a single line in a text file
Thank you for your reply.
I'm in the middle of building or creating a Windows (GUI) based program. I'm not going to lie, I'm not 100% sure what reader/writer stream actually is.
The code I was trying to use for this looked something like this or atleast the dim statement did:
Dim objwriter as new system.io.streamwriter ("C:\bla.txt")
-
Sep 22nd, 2011, 05:41 AM
#4
Re: Writing 4 or more strings to a single line in a text file
You can use formatting when you write to a StreamWriter.
Code:
objWriter.Write("{0}, {1}, {2}", string1, string2, string3)
For more information look up the definition at MSDN, you'll find it here.
For more information about string formatting look up the String.Format method.
-
Sep 22nd, 2011, 05:51 AM
#5
Thread Starter
Member
Re: Writing 4 or more strings to a single line in a text file
.................
Really--- Its that simple. I will have to try it later today.. Got to love staying up all night and working on a program that you have no idea where it will end up.
Regards
Kyle
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
|