merge values with last line in textfile

skaswani

Member
Joined
Oct 5, 2008
Messages
20
Programming Experience
Beginner
Hello to everyone, I am using Vb.net via VS 2010

I have a small issue,



my code is like this

Dim filename As String = "c:\test\a.txt"
Dim i As Integer =5
Dim objWriter As New System.IO.StreamWriter(filename)


objWriter.WriteLine("-}$")


if i=5 then
objWriter.WriteLine("ABC")

............



suppose if i value is 5 then code should print
objWriter.WriteLine("-}$") & objWriter.WriteLine("ABC") in same line
 
If you only want to write one line then why are you calling WriteLine twice? WriteLine writes a line. Call it twice and you write two lines. If you want to write text without a line break then call Write rather than WriteLine.

If you're using a StreamWriter and want to know how to do something with it, the first thing you should have done was read the MSDN documentation for the StreamWriter class. It explains how Write and WriteLine work. There's a Help menu in VS for a reason and you can even use the F1 key to jump to specific documentation on a type or keyword, which is a Windows standard.
 
Back
Top