Looks to me like you have code inside your class definition that is not inside a property or function definition.
Can you edit your post and put the code in the 'CODE' tags?Also, what is the error and what line is it being thrown at?
Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Geometry Imports ESRI.ArcGIS.Geodatabase Imports ESRI.ArcGIS.Carto Public Class Tool1 Inherits ESRI.ArcGIS.Desktop.AddIns.Tool #Region "Select Map Features by Attribute Query" '''<summary>Select features in the IActiveView by an attribute query using a SQL syntax in a where clause.</summary> ''' '''<param name="activeView">An IActiveView interface</param> '''<param name="featureLayer">An IFeatureLayer interface to select upon</param> '''<param name="whereClause">A System.String that is the SQL where clause syntax to select features. Example: "CityName = 'Redlands'"</param> ''' '''<remarks>Providing and empty string "" will return all records.</remarks> Public Sub SelectMapFeaturesByAttributeQuery(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer, ByVal whereClause As System.String) If activeView Is Nothing OrElse featureLayer Is Nothing OrElse whereClause Is Nothing Then Return End If Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast ' Set up the query Dim queryFilter As IQueryFilter = New QueryFilterClass queryFilter.WhereClause = whereClause ' Invalidate only the selection cache. Flag the original selection activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) ' Perform the selection featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, False) ' Flag the new selection activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) End Sub #End Region ' select coords and assign to variables by select Map Features by Atribute Query Dim row As Double Dim pX As Double Dim pY As Double SelectMapFeaturesByAttributeQuery(activeView, trig_srtm30, "FID=row") pX=trig_srtm30.X(Value) pY=trig_srtm30.Y(Value) #Region "Clear Selected Map Features" '''<summary>Clear the selected features in the IActiveView for a specified IFeatureLayer.</summary> ''' '''<param name="activeView">An IActiveView interface</param> '''<param name="featureLayer">An IFeatureLayer</param> ''' '''<remarks></remarks> Public Sub ClearSelectedMapFeatures(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer) If activeView Is Nothing OrElse featureLayer Is Nothing Then Return End If Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast ' Invalidate only the selection cache. Flag the original selection activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) ' Clear the selection featureSelection.Clear() ' Flag the new selection activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) End Sub #End Region ' Clear selection ClearSelectedMapFeatures(activeView, trig_srtm30) ' select polygon shapefile which will be moved by select Map Features by Atribute Query SelectMapFeaturesByAttributeQuery(activeView, poly_C1toend, "") ' move shapefile according to new coords Public Sub New() End Sub Protected Overrides Sub OnUpdate() Enabled = My.ArcMap.Application IsNot Nothing End Sub End Class
Hallo everyone,I am trying to make a tool in arcobjects using VStudio 2010 and VB (.net, framework 3.5). I want to select a particular shapefile, then select the first record of it (FID=0) and then assign the value of a particular field to variable. After that with a for loop I will take the values of that field for all the rows.I have made functions for all the actions (select layer by name, select row, select field by name) but it doesn't work. I get silly warnings and correction, but I am new to arcobjects and I can't handle it.Any help is welcomed
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.