Question: Create a Windows Forms application. Use the following names for the project and solution, respectively: Vacation Project and Vacation Solution. Save the application in the
Create a Windows Forms application. Use the following names for the project and solution, respectively: Vacation Project and Vacation Solution. Save the application in the VB2017\Chap09 folder.
The application will use two sequential access files named NeedToVisit.txt and Visited.txt. Copy the files from the VB2017\Chap09 folder to the Vacation Projects bin\Debug folder and then open both files. The NeedToVisit.txt file contains the names of five destinations that the user wants to visit. The Visited.txt file contains the names of three destinations that the user already visited. Close both .txt windows.
Create the interface shown in Figure 9-39. The File menu should have an Exit option.

Change the lstNeed controls Sorted property to True. Change the lstVisited controls SelectionMode and Sorted properties to None and True, respectively.
The frmMain_Load procedure should use the NeedToVisit.txt and Visited.txt files to fill the lstNeed and lstVisited controls, respectively. It should also select the first item in the lstNeed control. Code the procedure.
The Move to visited button should move the selected item from the lstNeed control to the lstVisited control. Code the appropriate procedure.
If at least one change was made to the list boxes, the frmMain_FormClosing procedure should use a message box to ask the user whether he or she wants to save the change(s). If the user clicks the Yes button, the procedure should save the items in both list boxes to the appropriate files before the form closes.
Save the solution and then start and test the application.
Provide the appropriate Windows shortcut key for the File|Exit menu item.
The form Load event should make sure the NeedToVisit.txt file exists, and if not, display a message and end the application. After the NeedToVisit.txt file has been read, then make sure the Visited.txt file exists, and if not, display a message and end the application.
Use a Do loop (with the .Peek method) to populate the list boxes, since the number of lines of data in each file could be unknown (due to previous runs of the application)
Before selecting the 1st item in the Need to visit list box make sure there is an item to select.
Make sure an item is selected in the Need to visit list box before attempting to move it to the Visited list box.
The Move button should add the selected item to the Visited list box and also remove the selected item from the Need to visit list box.
Use a class-level flag (a boolean variable) to indicate if changes to the list boxes have been made.
In the form Closing event, check the flag. If it indicates that a change has been made, display a message box with 3 buttons - Yes, No, and Cancel - asking if the changes should be saved . If Cancel is clicked, return to the application. If Yes is clicked, save the changes and end the application. If No is clicked, just end the application.
When saving the changes, I used a For loop, since the number of items in each list box is known.
There are 6 vacation destinations in the original NeedToVisit.txt file, not 5 as the text book says.
Vacation Destinations Need to visit: Visited IstNeec IstVisited Move to visited
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
