This can be done by using the is operator. Here is a simple function demonstrating this method:
Public Function RemoveObject(Collection As Collection, Object As Object)Dim vTemp As ObjectDim Index As Integer Index = 1 For Each vTemp In Collection If vTemp Is Object Then Collection.Remove Index Else Index = Index + 1 End If NextEnd FunctionIf there is only a single instance in the collecion, you can add an exit for:Public Function RemoveObject(Collection As Collection, Object As Object)Dim vTemp As ObjectDim Index As Integer Index = 1 For Each vTemp In Collection If vTemp Is Object Then Collection.Remove Index Exit For Else Index = Index + 1 End If NextEnd Function
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.
























