Dear all.

I have searched over 40 Youtubes and msdn to no avail.
I am trying to save more than one text box to a file, and of course load after.

Bla Bla

If DialogResult = DialogResult.OK Then
Dim SWriter As StreamWriter = New StreamWriter(SaveFileDialog.FileName)

SWriter.Write(TxtBx1.Text) comment 12345
SWriter.Write(TxtBx2.Text) comment absdr

SWriter.Close()
End If
Hope to save this in text file as 12345,absdr

Hope to load this back to the text boxes on load event. so TxtBx1.Text is 12345 and TxtBx2.Text is absdr

Would be fantastic to see the code / syntax of this.

Thanks.
Donovan

Originally Posted by Donovan Also
Hope to save this in text file as 12345,absdr

Save like this
Code:
SWriter.Write(TxtBx1.Text) & "," & SWriter.Write(TxtBx2.Text)

Originally Posted by Donovan Also
Hope to load this back to the text boxes on load event. so TxtBx1.Text is 12345 and TxtBx2.Text is absdr
Code:
        Dim SReader As StreamReader = New StreamReader("path\to\your\file")

TxtBx1.Text = r(0)
TxtBx2.Text = r(1)

SReader.Close()

Hi Thanks for that.

I have put this save code in and am getting an error message on the first & "end of statement expected" SWriter.Write(TxtBx1.Text) & "," & SWriter.Write(TxtBx2.Text)
Cheers

Sorry, my mistake

it should be
Code:
SWriter.Write(TxtBx1.Text & "," & TxtBx2.Text)

Hi 4x2y

I have solved this.

The syntax is in fact :- SWriter.Write(TxtBx1.Text & ",")
SWriter.Write(TxtBx2.Text)

Very much apreciated.

Another more simple way is to write each TextBox.Text to a line

Write
Code:
        Dim SWriter As StreamWriter = New StreamWriter("path\to\your\file")

SWriter.WriteLine(TxtBx1.Text)
SWriter.WriteLine(TxtBx2.Text)

SWriter.Close()
Code:
                Dim SReader As IO.StreamReader = New StreamReader("path\to\your\file")

SReader.Close()

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured