Private Sub DataStatistics() Dim pMxDoc As IMxDocument, pFLayer As IFeatureLayer Dim pCursor As ICursor, pStatResults As IStatisticsResults Set pMxDoc = ThisDocument Set pFLayer = pMxDoc.FocusMap.Layer(0) Set pCursor = pFLayer.Search(Nothing, False) Dim pData As IDataStatistics Dim pEnumVar As IEnumVariantSimple Dim value As Variant Set pData = New DataStatistics pData.Field = "JCODE" Set pData.Cursor = pCursor '取得されたいフィーチャクラスから取得したカーソル 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 '数値フィールド以外を指定するとArcMapがクラッシュする Debug.Print "平均 - " & pStatResults.Mean End Sub
DataStatistics の操作
2016/9/1 (木)