English

How To: Remove a generic object from ISet

Summary

The Remove method on the ISet interface expects a single argument, an IUnknown pointer.

Procedure

This sample code removes selected objects from an ISet returned by the GetObjectsRelatedToObject method.

Code:
Dim pObjSet As ISet
Set pObjSet = pRelationshipClass.GetObjectsRelatedToObject(pOriginFeature)

pObjSet.Reset

Dim i As Integer
Dim pObject As IObject
Set pObject = pObjSet.Next

For i = 0 To pObjSet.Count - 1
If Not pObject Is Nothing Then
If pObject.Value(pObject.Fields.FindField("Point_Name")) = "Lafayette" Then

MsgBox "Before Remove: " & pObjSet.Count
Dim pUnk As IUnknown
Set pUnk = pObject
pObjSet.Remove pUnk
MsgBox "After Remove: " & pObjSet.Count
End If
Set pObject = pObjSet.Next
End If
Next i