ComboBox.RemoveItem 方法 (Access)ComboBox.RemoveItem method (Access)

從指定下拉式方塊控制項所顯示的值清單中移除項目。Removes an item from the list of values displayed by the specified combo box control.


運算式RemoveItem(索引)expression.RemoveItem (Index)

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.


名稱Name 必要/選用Required/Optional 資料類型Data type 描述Description
IndexIndex 必要Required VariantVariant 要從清單移除的項目,以項目號碼或清單項目文字表示。The item to be removed from the list, expressed as either an item number or the list item text.


此方法只適用於表單上的清單方塊或下拉式方塊控制項。This method is only valid for list box or combo box controls on forms. 此外,控制項的RowSourceType屬性必須設定為 Value List。Also, the RowSourceType property of the control must be set to Value List.

清單項目號碼從零開始。List item numbers start from zero. 如果_Index_引數的值不會對應至現有的項目號碼或現有項目的文字,會發生錯誤。If the value of the Index argument doesn't correspond to an existing item number or the text of an existing item, an error occurs.

使用 AddItem 方法將項目新增至值的清單。Use the AddItem method to add items to the list of values.


此範例會將指定的項目移除清單方塊控制項中的清單。This example removes the specified item from the list in a list box control. 為搭配函數,您必須將其傳 ListBox 物件,代表在表單以及一個 Variant 值,代表要移除的項目在清單方塊控制項。For the function to work, you must pass it a ListBox object representing a list box control on a form and a Variant value representing the item to be removed.

Function RemoveListItem(ctrlListBox As ListBox, _ 
 ByVal varItem As Variant) As Boolean 
 ' Trap for errors. 
 ' Remove the list box item and set the return value 
 ' to True, indicating success. 
 ctrlListBox.RemoveItem Index:=varItem 
 RemoveListItem = True 
 ' Reset the error trap and exit the function. 
 On Error GoTo 0 
 Exit Function 
' Return False if an error occurs. 
 RemoveListItem = False 
End Function

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.