Save a (.txt) File On Form Closing
Page 1 of 1 • Share •
Save a (.txt) File On Form Closing
Things You'll Need
1 RichTextBox [RichTextBox1]
Select The Form_Closing Event
Type The Following Code:
This is all you need to do to save a (.txt) file when your form is closing.
To test your program, debug it then go to the location where you saved your file.
1 RichTextBox [RichTextBox1]
Select The Form_Closing Event
Type The Following Code:
- Code:
Dim reply
reply = MsgBox("Do you want to Save before you Exit?", 52)
If reply = 6 Then
Dim SFD As New SaveFileDialog
With SFD
.Filter = "Text Files (.txt)|*.txt"
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Dim SW As New IO.StreamWriter(.FileName)
For Each line As String In RichTextBox1.Lines
SW.WriteLine(line)
Next
SW.Flush()
SW.Close()
End If
End With
Else
End If
This is all you need to do to save a (.txt) file when your form is closing.
To test your program, debug it then go to the location where you saved your file.
conorsteel- Admin

- Number of posts: 13
Age: 16
Location: Kilmarnock, Scotland
Registration date: 2008-08-31

Permissions of this forum:
You cannot reply to topics in this forum





