Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Help fix tool to which uses a txtbox to make selection. pFeatureSelection broken

$
0
0
Hello all,
I'm trying to migrate some VBA code written in 9.2 into a Win7, Office 2010, 10.2 format and I'm having a little trouble as I'm very novice at programing. My tool is pretty basic that I'm trying to create. It uses a form with a textbox to which someone would paste in text in to be used as a selection. Its basically just a select by attributes with a custom form since all the selections are on the same field in the same layer. Layer = Forest Field = ID Format is always XX0000-0000. My tool runs through the code successfully but stops at the pFeatureSelection.SelectFeatures at the bottom below the pActiveView and does not make a selection. I can't figure out what is going on. I've tried pasting in what seems like updated code format but it does not like this barks at me. If anyone has suggestions it would be very appreciated.

Code:

Public Sub CommandButton1_Click()
   
                 
     
       
        Dim pStID As String
        Dim pMxDoc As IMxDocument
        Dim pMap As IMap
        Dim pActiveView As IActiveView
        Dim pFeatureLayer As IFeatureLayer
        Dim pFeatureSelection As IFeatureSelection
        Dim pQueryFilter As IQueryFilter
        Dim pEnumLayer As IEnumLayer
       
        Set pMxDoc = Application.Document
        Set pMap = pMxDoc.FocusMap
        Set pActiveView = pMap
             
        Set pEnumLayer = pMxDoc.FocusMap.Layers
        Set pFeatureLayer = pEnumLayer.Next
       
             
        Do Until pFeatureLayer Is Nothing
        If pFeatureLayer.Name = "Forest" Then
        Exit Do
        End If
        Set pFeatureLayer = pEnumLayer.Next
        Loop
       
        'txtID.pActiveSheet.Range("ID").Select
 
        'txtID.Selection.Copy
       
        'txtStID.Paste
                                 
        'txtID.pActiveSheet.Range("E1").Select
       
        'txtStID.Selection.Copy
               
        'txtID.pActiveSheet.Range("B1").Activate
       
            If pFeatureLayer Is Nothing Then
                MsgBox "It Is Empty"
                Exit Sub
            End If
       
        Set pFeatureSelection = pFeatureLayer
       
           
            pID = "[ID] IN (" & txtID.Text & ")"
       
           
      Set pQueryFilter = New QueryFilter
     
      pQueryFilter.WhereClause = pID
     
               
                   
         
      pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
              'THE PFEATURESELECTION LINE BELOW DOES NOT WORK. I DON'T KNOW WHY!!
      pFeatureSelection.SelectFeatures pQueryFilter, esriSelectionResultNew, False
     
               
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
     
       
        'THIS CODE BELOW SEEMS TO BE AN UPDATED VERSION BUT DOES NOT WORK
       
        ''pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
                ' Perform the selection using the user input.
        '' pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
       
     
     
     
End Sub


Viewing all articles
Browse latest Browse all 1374

Trending Articles