RemoveItem Method

See AlsoQXS27L              Example426U5O7>Low

Removes an item from a list box or combo box or removes a row from a grid control at run time

Syntax.

control.RemoveItem index

Remarks

The RemoveItem method has these parts:

Part               Description

 

control           List box, combo box, or grid control.

index             Integer representing the position within the control of the item or row to remove.  For the first item in a list box or combo box, or for the first row in a grid control,  index = 0.

 


See Also

AddItem Method2BIX3OB

Clear MethodPMJHM6


RemoveItem Method Example

The example uses RemoveItem to remove entries from a list box.  To try this example, paste the code into the Declarations section of a form with a list box control named List1.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim Entry, I, Msg                     ' Declare variables.

   Msg = "Choose OK to add 100 items to your list box."

   MsgBox Msg                            ' Display message.

   For I = 1 To 100                      ' Count from 1 to 100.

      Entry = "Entry " & I               ' Create entry.

      List1.AddItem Entry                ' Add the entry.

   Next I

   Msg = "Choose OK to remove every other entry."

   MsgBox Msg                            ' Display message.

   For I = 1 To 50                       ' Determine how to

      List1.RemoveItem I                 ' remove every other

   Next I                                ' item.

   Msg = "Choose OK to remove all items from the list box."

   MsgBox Msg                            ' Display message.

   List1.Clear                           ' Clear list box.

End Sub