Collection.Remove Method (String)
Removes an element from a Collection object.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
- Type: System.String
A unique String expression that specifies a key string that can be used, instead of a positional index, to access an element of the collection. Key must correspond to the Key argument specified when the element was added to the collection.
When Remove deletes an element from a collection, it decrements the collection's Count property by one. It also decrements the Index value of every element that formerly followed the deleted element in the collection.
If an element was added to the collection without a Key, you must use its Index to remove it.
This example illustrates the use of the Remove method to remove objects from a Collection object in the variable birthdays.
Following the four calls to the Add method, the Count property contains 4, element "Bill" has index value 1, and element "Pete" has index value 4.
Following the first call to Remove, Count is 3, element "Bill" is deleted, and element "Pete" has index value 3.
Following the second call to Remove, Count is 2, element "Mike" is deleted, and element "Pete" has index value 2.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.