AnsweredAssumed Answered

vb.net arcobjects spatial search sample

Question asked by littleleaf on Aug 5, 2014
Latest reply on Aug 6, 2014 by littleleaf

Hi,

 

I want to perform a spatial search on ArcMap 10.2, cannot find proper sample for vb.net, what I found is the code from VBA. When I trying to convert it to vb.net, I encounter reference problem, the code is as following:

 

Public Function SpatialQuery(pFeatureClassIN As esriGeoDatabase.IFeatureClass, _

                             searchGeometry As esriGeometry.IGeometry, _

                             spatialRelation As esriGeoDatabase.esriSpatialRelEnum, _

                             Optional whereClause As String = "" _

                             ) As esriGeoDatabase.IFeatureCursor

 

 

        Dim pSpatialFilter As esriGeoDatabase.ISpatialFilter

        Dim strShpFld As String

        Dim pFeatCursor As esriGeoDatabase.IFeatureCursor

        Dim pQueryFilter As esriGeoDatabase.IQueryFilter

 

 

        ' create a spatial query filter

        pSpatialFilter = New esriGeoDatabase.SpatialFilter

 

 

        ' specify the geometry to query with

        pSpatialFilter.Geometry = searchGeometry

 

 

        ' specify what the geometry file is called on the Feature Class that we will be querying against

        strShpFld = pFeatureClassIN.ShapeFieldName

        pSpatialFilter.GeometryField = strShpFld

 

 

        ' specify the type of spatial operation to use

        pSpatialFilter.SpatialRel = spatialRelation

 

 

        ' create the where statement

        pSpatialFilter.whereClause = whereClause

 

 

        ' perform the query and use a cursor to hold the results

        pQueryFilter = pSpatialFilter

        pFeatCursor = pFeatureClassIN.Search(pQueryFilter, False)

 

 

        SpatialQuery = pFeatCursor

 

 

    End Function

 

Then I got the following errors:

 

errorlist.jpg

 

Not sure is it because the library difference of ArcGIS version? or what kind of library missing in my vb file? what shoukd I do to make it work?

 

Thanks for your time.

Outcomes