Hello,I would like to insert the values of a row of an attribute table into an array. I know how to do this manually: Dim myArray()myArray= Array("21621", "21612", "21624", .....)But I was wondering if you can use a loop to get the values automatically (using VBA).Can anybody help? Thanks!
Dim pLayer as IFeatureLayer = pMap.Layer(0) 'gets the first layer in the TOC Dim pFSel as IFeatureSelection = pLayer Dim pFCursor as IFeatureCursor pFSel.SelectionSet.Search(Nothing, False, pFCursor) Dim myArray() As Array = New Array Dim i As Integer i = 0 Dim pFeat as IFeature pFeat = pFCursor.NextFeature Dim valForArray As String Do Until pFeat Is Nothing valForArray = pFeat.Value(pFeat.Fields.FindField("TheFieldName")) myArray.Insert(i + 1, valForArray) pFeat = pFCursor.NextFeature Loop
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.