Mega Code Archive

 
Categories / VB.Net Tutorial / Collections
 

Deleting the members of a collection

Option Strict On Public Module CollectionTest    Public Sub Main()       Dim weights As New Collection       weights.Add("ounces", "oz")       weights.Add("pounds", "lbs")       weights.Add("kilograms", "kg")       weights.Add("milligrams", "mg")       For ordinal As Integer = weights.Count To 1 Step -1          weights.Remove(ordinal)       Next       Console.WriteLine("The collection now has {0} items.", weights.Count)    End Sub End Module The collection now has 0 items.