ARCOBJECTS VBA PDF

Consult the Visual Basic Reference, the online help file that displays when you click Microsoft Visual Basic Help in the Help menu of the VBA Editor for generic help on the user interface, conceptual topics, how-to topics, language reference topics, customizing the Visual Basic Editor, and user forms and controls. In the VBA development environment you can add modules, class modules, and user forms to the default project contained in every ArcGIS application document. A project can consist of as many modules, class modules, and user forms as your work requires. A project is a collection of items to which you add code. A module is a set of declarations followed by procedures—a list of instructions that your code performs. A class module is a special type of module that contains the definition of a class, including its property and method definitions.

Author:Doulkree Kazizil
Country:Mali
Language:English (Spanish)
Genre:Education
Published (Last):8 July 2018
Pages:442
PDF File Size:20.90 Mb
ePub File Size:16.9 Mb
ISBN:986-9-81890-153-5
Downloads:60701
Price:Free* [*Free Regsitration Required]
Uploader:Sashakar



They are authored in. They provide a declaratively based framework for creating a collection of customizations that can be conveniently packaged in a single compressed file that is easily shared. You need to pick the option that best suits your application. This Exercise The VBA sample for this exercise is a simple form that reads the selected county on the map and displays its information on the form. If the ArcGIS templates do not show up when creating a new project, make sure you have.

NET Framework 3. Figure 1: First wizard screen encountered when creating an add-in Because this article is intended to demonstrate the ease of converting VBA code to. NET, some of the description of the project creation process is not detailed. For more detailed information, Esri has created a very good example.

The Add-ins Wizard will pop up. Fill out all the information on the welcome screen—this will be the information that is seen when adding the add-in to ArcMap Figure 1.

Click Next to bring up Add-in Types. For this example, all that is needed is a button, so check the Button checkbox, fill in the fields, and click the Finish button. This will create the Add-in project and the Button tool Figure 2.

Give the form a width of px and a height of px. Also, change the form text property to County Info and set the topmost property to True. This will keep the form in front of ArcMap. Figure 2: Second wizard screen for creating command button To make the form look like a VBA form Figure 3 , add some controls to it.

With Visual Studio and. Because these labels will not interact with the code, leave the default names for these controls e. Add four more labels to the form that will be used to display the values from the selected county.

Add two buttons to the form. Call one btnRead and set its text property to Read Data. Call the other one btnClose and set its text property to Close. Figure 3: Side-by-side view of VBA form and. It must be manually re-created. However, as demonstrated in the next section, the code is reusable and easily upgraded. Reusing the Code The VBA sample is a simple program that has four parts: A button on a toolbar to show the form A button to read the selected item Some labels to display the data A button to close the form There is one other major piece: a subroutine called ReadData.

This is where the work is done in the VBA sample, and this code needs to be copied and converted. An easy way to do this is to export the form to be upgraded out of the VBA editor and open the exported file with the. Copy the subroutine and paste it into the newly created form in the add-in project. In this example, open the included file called Form1. Right-click the form created in Visual Studio and pick View Code.

Paste the subroutine in the code behind. Figure 4: Code view with errors and import statements Fixing Errors When the code is pasted, several errors will show up. Most of these will go away once the right references are added. This example requires two references. Carto and Esri.

Geodatabase from the. NET tab. This is easily fixed by adding import statements at the top of the code. Doing this lets Visual Studio use the shorter names also. At the very top of the code for the form, above the public class, add three import statements Figure 4. Type Imports Esri. Carto Imports Esri. Geodatabase Once the imports and references have been added, the number of errors decreases from 10 to 5. Resetting Properties The next fix addresses something that happens a lot when converting code from VBA to.

To set the text to the labels in VBA, the property is called Caption. NET, to set the text to the label, the property is called Text. This is easy enough to fix. One way would be to simply replace the word caption with the word text. Another way demonstrates one of the benefits of using the Visual Studio environment.

Go to the error lblCountyName. Caption and delete. Place the cursor at the end of the word lblCountyName and press the period key.

This brings up Intelli-Sense and shows all the properties available to set on the label. Scroll down and pick the word Text. Figure 5: Side-by-side view of VBA code and. NET code While it might have been easier to just retype Caption to Text, if the correct property is not known, this is a very useful feature. After changing the labels from caption to text, only one error remains.

This is really the only major error in converting the code. To fix this error, change ThisDocument to My. This will switch back to the Form Design view. Select the Read Data button and double-click it. This will add the click event handler for the button. Open the file Form1. Switch to the Form Design view again and double-click the Close button. This adds the close button click event handler. In VBA, all that was in this event was the command End, which will not work in the add-in.

To accomplish the same task in the new code, just type Me. Close in the btnClose subroutine. All the code has been converted for the form. Figure 5 shows the code before and after. Not much has changed in the conversion between VBA and the add-in. However, note that when pasting the code, Visual Studio did convert some code automatically. In this example, it removed the word Set and it put parentheses around the command pFLayer.

One More Thing There is one last thing to do before the code is ready to use. When the add-in project was created, the Button checkbox was checked. This added a command button to the project.

From the Solution Explorer, right-click FormButton. This opens the code for the button. Show This tells the button when it is clicked to create a new form and show it.

Now go to the Build menu and build the project. After the project is built, the files are bundled as an add-in and automatically installed in ArcMap. It contains counties and states for the entire United States. Go to the Customize menu and pick Add-In Manager Figure 6 , verify the add-in loaded, and close the dialog box.

Go to the Customize menu and pick Customize Mode. In the Customize dialog box, click the Commands tab Figure 7. Choose Add-In Controls from Categories the category that was defined when creating the add-in. Drag the My Form Button from Commands and drop it on any toolbar. Close the Customize dialog box.

In ArcMap, select a county on the map. Click the button to show the county form that was just dragged to the toolbar. This opens the County Info dialog box. With a county selected, click the Read Data button on the dialog box. This will read the selected county information and display it on the form.

Click the Close button to close the County Info dialog box. This code could be improved. The add-in model has many more options.

68HC08 DATASHEET PDF

Subscribe to RSS

.

55WL30MS D PDF

.

UNDERSTANDING WOOD BRUCE HOADLEY PDF

.

Related Articles