Here is the full code: (upon selecting a feature, it should display field name and field values)
Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Integer, ByVal Y As Integer)
Dim pMxdoc As IMxDocument
Dim pActiveView As IActiveView
Dim pEnumLayer As IEnumLayer
Dim pLayer As ILayer
Dim pFlayer As IFeatureLayer
Dim pFeatureSelection As IFeatureSelection
Dim pSelectionSet As ISelectionSet
Dim pEnumFeat As IEnumFeature
Dim pFeat As IFeature
Dim MC As Double
Dim pFeatSel As IFeatureSelection
Dim pMap As IMap
Dim pfeatureclass As IFeatureClass
Dim fields As IFields
Dim C As Long
Dim ii As Long
Dim Field As IField
Dim intFldIndex As Integer
Dim fieldname As String
Dim fieldvalue As Integer
Dim value As Long // should it be different (string/integer/double or what?)
Dim a As Integer
Dim namelist As String
pMxdoc = m_application.Document
pActiveView = pMxdoc.FocusMap
pMap = pMxdoc.FocusMap
pFlayer = pMxdoc.SelectedLayer
pfeatureclass = pFlayer.FeatureClass
fields = pfeatureclass.Fields
pFeatureSelection = pFlayer
pSelectionSet = pFeatureSelection.SelectionSet
' verify the name of the selected layer
Dim count As Integer
count = pSelectionSet.Count
If pSelectionSet.Count <> 0 Then
MsgBox("You have have selected: " & pFlayer.Name)
End If
' get the field count
C = fields.FieldCount
MsgBox("There are: " & C & "fields in this layer")
pEnumFeat = pMxdoc.FocusMap.FeatureSelection
pFeat = pEnumFeat.Next
' loop through each field and add the field name to a list
For ii = 0 To fields.FieldCount - 1
Field = fields.Field(ii)
fieldname = Field.Name
fieldvalue = Field.VarType
value = pFeat.Value(ii) // having trouble in getting the value
namelist = namelist & fieldname & value & Chr(13)
Next
' diaplay the list of field names in a messagebox
MsgBox(namelist, , "field names")
' loop to get the field value
'For a = 0 To pFeat.Fields.FieldCount - 1
' value = pFeat.Value(a)
' namelist = namelist & value & Chr(13)
'Next
'MsgBox(namelist, , "field value")
End Sub