Public Sub test() Dim pMXDocument As IMxDocument Set pMXDocument = ThisDocument Dim pMap As IMap Set pMap = pMXDocument.FocusMap Dim pLayer As ILayer Set pLayer = pMap.Layer(0) Dim pFeatureLayer As IFeatureLayer Set pFeatureLayer = pLayer Dim pFeatureClass As IFeatureClass Set pFeatureClass = pFeatureLayer.FeatureClass Dim pTable As ITable Set pTable = pFeatureClass Dim pTableSort As ITableSort Set pTableSort = New TableSort With pTableSort .Ascending("Strahler") = False Set .Table = pTable Set .QueryFilter = Nothing .Fields = "Strahler" .Sort Nothing End With ' Get sorted cursor and write to debug window Dim pCursor As ICursor Set pCursor = pTableSort.Rows Dim pRow As IRow Set pRow = pCursor.NextRow Do While Not pr Is Nothing Debug.Print pRow.Value(pRow.Fields.FindField("Strahler")) Set pRow = pCursor.NextRow Loop End Sub
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.