pDoc = m_pApp.Document 'setting m_pApp is a seperate question for another thread
pMap = pDoc.FocusMap
Dim pFCursor As IFeatureCursor
Dim pSelectionSet As ISelectionSet
Dim pFSelection As IFeatureSelection
pFSelection = pMap.Layer(0) 'just use the first layer in the TOC for simplicity
pSelectionSet = pFSelection.SelectionSet
''set the pfeaturecursor
pFCursor = Nothing
''Get a cursor from the selected features
pSelectionSet.Search(Nothing, False, pFCursor)
Dim curTextValue As String
Dim curIntegerValue As Integer
Dim curDateValue As DateTime
Dim pFeat As IFeature
pFeat = pFCursor.NextFeature
Do Until pFeat Is Nothing
curTextValue = pFeat.Value(pFeat.Fields.FindField("YourTextFieldName"))
curDateValue = pFeat.Value(pFeat.Fields.FindField("YourDateFieldName"))
curIntegerValue = pFeat.Value(pFeat.Fields.FindField("YourIntegerFieldName"))
pFeat = pFCursor.NextFeature
Loop
Private Function Get_Lyr(ByVal sLayerName As String) As IFeatureLayer Dim i As Integer Dim pLayer As IFeatureLayer pLayer = Nothing pDoc = m_pApp.Document pMap = pDoc.FocusMap For i = 0 To pMap.LayerCount - 1 If pMap.Layer(i).Name = sLayerName Then pLayer = pMap.Layer(i) pLayer.Selectable = False Exit For End If Next Return pLayer End Function
Dim pFCursor As IFeatureCursor
Dim pSelectionSet As ISelectionSet
Dim pFSelection As IFeatureSelection
pFSelection = Get_Lyr("YourLayerNameGoesHere") 'use the new Get_Lyr function
pSelectionSet = pFSelection.SelectionSet
''set the pfeaturecursor
pFCursor = Nothing
''Get a cursor from the selected features
pSelectionSet.Search(Nothing, False, pFCursor)
Dim curTextValue As String
Dim curIntegerValue As Integer
Dim curDateValue As DateTime
Dim pFeat As IFeature
pFeat = pFCursor.NextFeature
Do Until pFeat Is Nothing
curTextValue = pFeat.Value(pFeat.Fields.FindField("YourTextFieldName"))
curDateValue = pFeat.Value(pFeat.Fields.FindField("YourDateFieldName"))
curIntegerValue = pFeat.Value(pFeat.Fields.FindField("YourIntegerFieldName"))
pFeat = pFCursor.NextFeature
Loop