View contents of this chapter

Removing Items

To delete items from the list box control use the RemoveItem method. For example, to remove the second list item use:

lstNames. RemoveItem 1

As the program removes items, the index values automatically renumber.

Play Sound List box index values work a lot like arrays.

To remove all the items from a list box use:

intTotal = lstNames.ListCount   'save the value
For intI = 1 To intTotal
  lstNames.RemoveItem 0
Next intI

The ListCount property keeps a running total of the number of items in the list. ListCount is always one greater than the highest ListIndex.

Play Sound The list box control's Clear method clears all items immediately without requiring a loop.

 



© Universal Teacher Publications        INDEX Previous Screen Next Screen