HOW TO
This article shows how to use IFeatureClass::FeatureCount to return a count of features in the layer or the number of features that satisfy a query.
Code:
Sub FeatureCount()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
'Get the first layer in the map
Dim pLayer As IFeatureLayer
Set pLayer = pDoc.FocusMap.Layer(0)
Dim pFc As IFeatureClass
Set pFc = pLayer.FeatureClass
'Get a count of all the features
MsgBox pFc.FeatureCount(Nothing)
End Sub
Code:
Sub FeatureCount()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
'Get the first layer in the map
Dim pLayer As IFeatureLayer
Set pLayer = pDoc.FocusMap.Layer(0)
Dim pFc As IFeatureClass
Set pFc = pLayer.FeatureClass
'Create a Query Filter
Dim pQF As IQueryFilter
Set pQF = New QueryFilter
pQF.WhereClause = "STATE_NAME = 'California'"
'Get a count of all the features
MsgBox pFc.FeatureCount(pQF)
End Sub
Article ID:000004859
Get help from ArcGIS experts
Download the Esri Support App