You've gotten feedback from a user of your word processor, SuperDuperTextPro, and it seems they've written a 600-page novel with the program and now find there's no way to save it to disk. Can you help? They will keep their computer on until they hear from you.
You use the SaveFile method to save the text in a rich text box to disk, and the LoadFile method to read it back. And doing so is easy. To see how this works, take a look at the RichTextBoxes example on the CD-ROM; when you click the "Save and restore text", the text in the bottom rich text box (RichText3) is written to a rich text file, text.rtf, then read back in and stored in the top rich text box (RichText1):
Private Sub Button6_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button6.Click RichTextBox3.SaveFile("text.rtf") RichTextBox1.LoadFile("text.rtf") End Sub
You can see this at work in Figure 5.12. That's all it takes-now we've written RTF to a file, and read it back in.
Many word processors, such as Microsoft Word, support RTF files, so you can now write formatted text files that such word processors can read in and use.