Library tutorials & articles
ListBox Control
Removing Items
To remove an item from a listbox during design time, select the Items property box, and press the drop down button. Select the items you want to remove and press Delete. Press Return to apply the changes, Esc to cancel.
To add remove an item from a list box during runtime, you can use the following syntax:
List1.RemoveItem Index
where Index is a integer representing the list index of the item to be removed. So if you use the previous example, David would have a list index of 0 (first item) , Paul's would be 1, and Sarah's 2. Note that if the listbox is sorted, the list index will change as items are added. The following code removes the selected item, and the first item on the list.
' Remove the first item
List1.RemoveItem 0
' Remove the selected item
List1.RemoveItem List.listindex
The listindex property returns the listindex of the currently selected item.
To remove all the items from a list box simply use the following statement:
List1.Clear
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
Suppose I have numeric values in my listbox. How do I add them and display the result on a message box.
This thread is for discussions of ListBox Control.