-
write to text file
Hi
I want to write the user input data to the text file. I want it to be in same line like this
G1 Z1. F80.
If i use my coding like this is not working:
Code:
Dim FILENAME As String = "C:\kaya.txt"
Dim objStreamWriter As StreamWriter
objStreamWriter = File.AppendText(FILENAME)
objStreamWriter.WriteLine("G1 " & TextBox2.Text, "F " & TextBox3.Text)
' Close the stream
objStreamWriter.Close()
if i change it like this :
Code:
objStreamWriter.WriteLine("G1 " & TextBox2.Text)
objStreamWriter.WriteLine("F " & TextBox3.Text)
It become two lines. How can i solve this problem?
Can any one help me.
-
Re: write to text file
Try this method
Code:
'Open the File for writing
Dim sw As New System.IO.StreamWriter("C:\text.txt", True)
'Write at the end
sw.WriteLine("TEsst1")
'Close the stream
sw.Close()
sw.Dispose()
-
Re: write to text file
But i want the G1 and F to be in same line not in two lines. Your code still give me a same answer
-
Re: write to text file
I am not getting you... I think you are dumping forum with Text File question :wave::wave:
-
Re: write to text file
Look at the help file on the StreamWriter object, specifically the Write methods. Or do you want someone to write the code for you?
-
Re: write to text file
Try this:
Code:
objStreamWriter.Write("G1 " & TextBox2.Text)
objStreamWriter.Write("F " & TextBox3.Text)
(using objStreamWriter.Write instead of objStreamWriter.WriteLine)