Actually, I have two polygon feature classes (RoadPolygon and AsstPolygon). The user selects a RoadPolygon and my code can find out all AsstPolygon which intersect with the selected RoadPolygon. I already write some code in VBA but seem does not work, anyone can help ?
' Find out the correct layer of RoadPolygon and AsstPolygon
For i = 0 To (pMap.LayerCount - 1)
If pMap.Layer(i).Name = "RoadPolygon" Then
Set RoadLayer = pMap.Layer(i)
End If
If pMap.Layer(i).Name = "RoadAssetPolygon" Then
Set AssetLayer = pMap.Layer(i)
End If
Next i
' Build a spatial filter
Dim spatialFilter As ISpatialFilter
Set spatialFilter = New spatialFilter
With spatialFilter
' Set .Geometry = pMap.FeatureSelection ? ,pPointCollection ?, pFeature 'I don't know
.GeometryField = AsstLayer
.SpatialRel = esriSpatialRelIntersects
End With
Dim featureSelection As IFeatureSelection
Set featureSelection = AsstLayer
featureSelection.SelectFeatures spatialFilter, esriSelectionResultNew, False
pDoc.ActiveView.Refresh
'Dim featureSelection As IFeatureSelection
'Set featureSelection = AsstLayer
'featureSelection.SelectFeatures spatialFilter, esriSelectionResultNew, False
'pDoc.ActiveView.Refresh