Question: 5 5 6 Chapter 8 Arrays and More Tutorial 8 - 1 0 : Building a List from user input In this tutorial, your will

556
Chapter 8 Arrays and More
Tutorial 8-10:
Building a List from user input
In this tutorial, your will rewrite the application from Tutorial 8-2 that let the user input and save the names of friends. In this new version, the names will be saved in a List (of String) object. After entering the names, the user can click a button and view all the names in a list box.
Step 1: Create a new Windows Forms application named Friend List 2. Place a Label, a ListBox, a TextBox, and two Button controls on the form. Use Figure 8-45 as a guide when naming the controls.
Figure 8-45 Controls in the Friend List application
Step 2: Open the Code window and inside the form class write the class-level variable declaration shown here in bold (in line 2):Step 3: Create the following Click handler for the Add button:The 1stNames. Add statement adds the contents of the text box to the list of strings. The text box is cleared to prevent the user from accidentally clicking the button twice and adding the same name. The Focus method is called so the user can type a new name into the text box.Step 4: Next, you will create a Click handler for the Show All button that copies the contents of the 1stNames list to the list box named 1stFriends:Private Sub btnShow_Click(...) Handles btnShow.Click
Display all names in the list box.
Dim strName As String
5 5 6 Chapter 8 Arrays and More Tutorial 8 - 1 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!