Public Sub SelectMapFeaturesByAttributeQuery(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer, ByVal whereClause As System.String)
        If activeView Is Nothing OrElse featureLayer Is Nothing OrElse whereClause Is Nothing Then
            Return
        End If
        Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast
        ' Set up the query
        Dim queryFilter As IQueryFilter = New QueryFilterClass
        queryFilter.WhereClause = whereClause
        ' Invalidate only the selection cache. Flag the original selection
        activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
        ' Perform the selection
        featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
        ' If PID found, Flag the new selection
        If featureSelection.SelectionSet.Count() = 0 Then
            MsgBox("Can't find the PID")
        Else
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
        End If
        ' Zoom to selected feature, if checkmarked
        If CheckBox1.CheckState = 1 Then
            Dim pUID As New UID
            pUID.Value = "esriArcMapUI.ZoomToSelectedCommand"
            My.ArcMap.Application.Document.CommandBars.Find(pUID).Execute()
        End If
        ' Display Owner's Name and PAN in message box
        Dim cursor As IFeatureCursor
        Dim feature As IFeature
        Dim patspan As String
        Dim taxname As String
        featureSelection.SelectionSet.Search(Nothing, False, cursor)
        feature = cursor.NextFeature
        patspan = feature.Fields.FindField("patspan")
        taxname = feature.Fields.FindField("taxname")
        Do Until feature Is Nothing
            MsgBox("PAN: " + feature.Value(patspan) + vbNewLine + "Owner's Name: " + feature.Value(taxname))
            feature = cursor.NextFeature
        Loop   
 End Sub
End Class
					
				
			
			
				
			
			
				Solved! Go to Solution.
featureSelection.SelectionSet.Search(Nothing, False, cursor)
featureSelection.SelectionSet.Search(Nothing, False, cursor)
cursor = featureLayer.Search(Nothing, False)
haha, it's not really working, because it returns the values of the first row, in the attribute table. I just want the values of the selected feature.
cursor = featureLayer.Search(Nothing, False)
ICursor cursor = null; featureSelection.SelectionSet.Search(null, false, cursor)
Dim cursor as ICursor cursor = Nothing featureSelection.SelectionSet.Search(Nothing, False, cursor)
