Lab 9.1 - Text Editor 1

Random Text

Text editors are essential to all sorts of computer applications. For example, this web page was written in a text editor.

Create a rudimentary text editor. Your form should have a one-line Text Box for the file name, a TextBox with the Multiline property set to True (complete with vertical scroll bar) for the text, and two Buttons: Open and Save. The Open and Save button should use the filename in the first Text Box to open the file for reading or writing (don't worry about dialog boxes just yet).

If the user clicks Open, the contents of the file in the first Text Box is read and put into the second Text Box. If the user clicks Save, the text in the second Text Box is saved to the file in the first Text Box. You should include some code into your program to keep track of whether the document has been changed before Opening another file or quitting, and use it to warn the user that they may lose some of their work (use the FormClosing event for this).

Use your editor to make a text file for testing. Use it to test your implementation of reading from and writing to disk.

HINTS: For the love of any and all deities of computing, don't forget to CLOSE YOUR FILES when you're done reading or writing them.

As always, design a useful and proper interface, and don't waste real estate.