Your mission: Write a Windows application that gets names and e-mail addresses from the user and displays a list of all of the user's contacts. Each time the user enters a new contact, he/she should able to see it added to a list of previously stored contacts. For example, in the following sample output below, after the user clicks the "Add Contact" button, the list will include John Mann's contact information at the bottom.

Sample output: See image.

Best practice: First, make sure to read through this week's lecture and textbook readings to get ideas about how to work with files. Then, before attempting a GUI application, just try implementing a short console application to open an existing .txt file, add some lines to it, and then close it. Use Windows Explorer to navigate to the file, open it, and see if your program worked. If it did, then try to open the .txt file from your console app and read data from it. Once you have that working, try the same operations in the form of a GUI app. Refer to the textbook for useful examples.

Note: Make sure to first create a .txt file in your project's bin/Debug folder to hold the contact info.

When designing the GUI, consider initially disabling the e-mail textbox and the button until all information is entered. Redisable them when the button is clicked. Note that you can also use the Tab Index property of GUI objects to set their order of use.

Pseudocode:

  • When the "Add Contact" button is clicked
  • Open an output file stream for appending
  • Write the contact's name and e-mail address to the file
  • Close the file stream
  • Clear the list
  • Open an input file stream for reading
  • Add each line of the file to the list
  • Close the file stream
  • When the form closes Close the input and output file streams
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.