In this exercise, you learn how to use the Items collections Insert, Remove, and RemoveAt methods. Open

Question:

In this exercise, you learn how to use the Items collection’s Insert, Remove, and RemoveAt methods. Open the Items Collection Solution.sln file contained in the VB2017\Chap05\Items Collection Solution folder. 

a. The Items collection’s Insert method allows you to add an item at a desired position in a list box during run time. The Insert method’s syntax is object.Items.Insert(position, item), where position is the index of the item. Code the btnInsert_Click procedure so it adds your name as the fourth item in the list box. (Recall that the first item in a list box has an index of 0.) 

b. The Items collection’s Remove method allows you to remove an item from a list box during run time. The Remove method’s syntax is object.Items.Remove(item), where item is the item’s value. Code the btnRemove_Click procedure so it removes your name from the list box. 

c. Like the Remove method, the Items collection’s RemoveAt method also allows you to remove an item from a list box while an application is running. However, in the RemoveAt method, you specify the item’s index rather than its value. The RemoveAt method’s syntax is object.Items.RemoveAt(index), where index is the item’s index. Code the btnRemoveAt_Click procedure so it removes the second name from the list box.

d. Save the solution and then start the application. Click the Insert button to add your name to the list box. Click the Remove button to remove your name from the list box. Click the RemoveAt button to remove the second name from the list box. Click the Exit button.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: