RemoveItem

<< Click to Display Table of Contents >>

 

RemoveItem

RemoveItem(pvargIndex)

Removes items from a Combo. This method has the pvargIndex parameter, which specifies a row to remove, starting at 0 (zero). That is, the first element is 0 (zero), the second element is 1 (one), and so on. The next script contains an example of using this method.

Sub CommandButton2_Click()
  ComboBox1.SetFocus
  ' Check if the list contains selected data
  If ComboBox1.ListCount >= 1 Then
    ' If there is no selection,
    ' selects the last item.
    If ComboBox1.ListIndex = -1 Then
      ComboBox1.ListIndex = ComboBox1.ListCount – 1
    End If
    ComboBox1.RemoveItem(ComboBox1.ListIndex)
  End If
End Sub

Was this page useful?