【正文】
icrosoft Visual Basic development system (Learning Edition, Professional Edition, and Enterprise Edition) and Visual Basic Scripting Edition (VBScript). VBA is an embeddable programming environment designed to enable developers to build custom solutions using the full power of Microsoft Visual Basic. Developers using applications that host VBA can automate and extend the application functionality, shortening the development cycle of custom business solutions. What are the differences between Visual Basic, VBA, and VBScript? When would we use one over another? Visual Basic is a standalone tool for creating separate software ponents, such as executable programs, COM ponents and ActiveX Controls, and is useful when you must build a specialized solution from scratch. VBA offers the same powerful tools as Visual Basic in the context of an existing application, and is the best option for customizing software that already meets most of your needs. VBScript is a lightweight version of the Visual Basic language, and is designed specifically for use on Web pages. While scripting can sometimes be used for simple automation, VBA is the premier technology designed specifically for application automation. Unlike VBA, VBScript does not have an IDE. Which Microsoft applications include Visual Basic for Applications? Visual Basic for Applications is a core ponent in Microsoft Office XP, and is integrated into Microsoft Access, Microsoft Excel, Microsoft FrontPage, Microsoft Outlook, Microsoft PowerPoint, and Microsoft Word. VBA is included with Microsoft Office 97 (Access, Excel, PowerPoint, and Word) as well as Microsoft Project 98. The VBA development environment First you39。ll do your work that are specific to the ESRI applications. 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, howto 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 梐 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. A user form is a container for user interface controls, such as mand buttons and text boxes. ArcMap has a default project associated with its document that39。ll see another project listed in the Project Explorer called Normal (). Normal is, in fact, a template for all documents. It39。s mands. Since any modifications made to Normal will be reflected every time you create or open a document, you should be careful when making changes to Normal. In ArcMap, users can start by opening a template other than the default template. These templates are available to them in the New dialog box. From a developer39。 it is listed in the Project Explorer as the TemplateProject followed by its filename. This project can store code in modules, class modules, forms, and any other customizations, such as maps with data, page layout frames, and so on. Any modifications or changes made to this base template are reflected only in documents that are derived from it. In ArcCatalog, Normal () is the only project that appears in the Project Explorer. There is no default Project in ArcCatalog, and you can39。ve invoked the Visual Basic Editor, you can insert a module, class module, or user form. Then you insert a procedure or enter code for an existing event procedure in the item39。s objects available in your code. Once a reference is set, the referenced objects are displayed in the development environment39。s modules, class modules, and user forms. To add a macro to a module ArcMap and ArcCatalog both provide a shortcut for creating a simple macro in a module. 1. Click the Tools menu, point to Macros, then click Macros. 2. Type the name of the macro you want to create in the Macro name text box. If you don39。s name with a name and a dot stores it in a module with the specified name. If the module doesn39。s title, type, accelerator table, mand bars collection, parent application, and Visual Basic project. Modules and class modules can contain more than one type of procedure: sub, function, or property. You can choose the procedure type and its scope when you insert a procedure. Inserting a procedure is like creating a code template into which you enter code. Every procedure has either private or public scope. Procedures with private scope are limited to the module that cont