Finds the specified search string in the given attribute fields.
[Visual Basic 6.0] Function Find(
ByVal Search As String, _
ByVal Contains As Boolean, _
ByVal Fields As Variant, _
ByVal TrackCancel As ITrackCancel _
) As IArray
[Visual Basic .NET] Public Function Find ( _ ByVal Search As String, _ ByVal Contains As Boolean, _ ByVal Fields As Object, _ ByVal TrackCancel As ITrackCancel _ ) As IArray
[C#] public IArray Find ( string Search, bool Contains, object Fields, ITrackCancel TrackCancel );
[Java] public IArray find ( String Search, Boolean Contains, Object Fields, ITrackCancel TrackCancel ) throws IOException, AutomationException
[C++] HRESULT Find( BSTR Search, VARIANT_BOOL Contains, VARIANT Fields, ITrackCancel* TrackCancel, IArray** ppArrObj );
Parameters
Search [in]
Search is a parameter of type BSTR
Contains [in]
Contains is a parameter of type VARIANT_BOOL
Fields [in]
Fields is a parameter of type VARIANT
TrackCancel [in]
TrackCancel is a parameter of type ITrackCancel
ppArrObj [out, retval]
ppArrObj is a parameter of type IArray
This method returns an reference to an Array of FeatureFindData objects. To search, pass in a reference to an Fields object along with the search string and a boolean option to return features that have attributes that contain the string. If Contains = False, only objects with an attribute that consists of the entire search string will be returned.
The following VBA example demonstrates how to do a simple search for features using IFind::Find.
Public Sub SampleFind()
Dim pFind As IFind
Dim pMxDoc As IMxDocument
Dim pFeatureLayer As IFeatureLayer
Dim pTrackCancel As ITrackCancel
Set pMxDoc = ThisDocument
Set pFeatureLayer = pMxDoc.FocusMap.Layer(0)
Set pFind = pFeatureLayer
Dim pArray As IArray
' "3090" is what I am searching for
Set pArray = pFind.Find("Hill", True, pFind.FindFields, pMxDoc.ActiveView.ScreenDisplay.CancelTracker)
If pArray Is Nothing Then
MsgBox "No Features were found"
Exit Sub
End If
Debug.Print pArray.count
Dim pFeatureFindData As IFeatureFindData2
Dim count As Long
'the array is an array of FeatureFindData objects
For count = 0 To (pArray.count - 1)
Set pFeatureFindData = pArray.Element(count)
'do something with the feature
MsgBox "Found Feature: " & pFeatureFindData.Feature.OID & " in Layer " & pFeatureFindData.Layer.Name
Next count
End Sub