ArcObjects Component Help  (Core)    

DataStatistics Example

The following code uses a DataStatistics object to create a list of unique values in the "PIP_SIZE" field and also display the mean of these values (notice that the cursor must be reset to obtain the mean value after accessing the unique values):

[Visual Basic 6.0]
Dim pMxDoc As IMxDocument, pFLayer As IFeatureLayer, pData As IDataStatistics Dim pCursor As ICursor, pStatResults As IStatisticsResults Set pMxDoc = ThisDocument Set pFLayer = pMxDoc.FocusMap.Layer(0) Set pCursor = pFLayer.Search(Nothing, False) Set pData = New DataStatistics pData.Field = "PIP_SIZE" Set pData.Cursor = pCursor Dim pEnumVar As IEnumVariantSimple, value As Variant Set pEnumVar = pData.UniqueValues value = pEnumVar.Next Do Until IsEmpty(value) Debug.Print "value - " & value value = pEnumVar.Next Loop Set pCursor = pFLayer.Search(Nothing, False) Set pData.Cursor = pCursor Set pStatResults = pData.Statistics Debug.Print "mean - " & pStatResults.Mean

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.