What Is Visual Basic?

Visual Basic for Applications is an application-specific offshoot of the larger Visual Basic (VB) programming language. VB and VBA are identical in syntax (the commands and command structures you use to create programs), so if you already know VB, you can easily switch to the VBA programming environment.

Microsoft has worked hard to make programming with VBA relatively easy, using English language terms strung together to tell your computer what to do. If you’ve programmed in the past, you should find VBA fairly easy to learn. If you haven’t programmed before, the learning curve will be a little steeper because you first have to learn to think like a computer. But the hardest part about using VBA to automate Microsoft Project is learning Project, not learning VBA. Project is an accomplished tool for a number of project management tasks, but Microsoft realized that there was no way it could anticipate the exact needs of all its users; therefore, it enabled you to enhance Project by programming code and forms in VBA.

Visual Basic is a complete and powerful event-driven language, which means that each component can operate independently of the rest of the program. When an event occurs, VB responds by running the procedure that was defined for that specific event, if any. If no procedure was defined for the event, nothing happens. These event procedures are tied to the controls that you place on your forms for user interaction, or to use Project or Windows features. For example, the Common Dialogs control adds the capability to use system-based Open and Save dialog boxes with only a few lines of code.

Note 

Don’t confuse event-driven programming with object-oriented programming languages. A programming language can be event driven, object oriented, or both. For example, programs such as Visual C++ and Delphi are both event driven and object oriented. These languages (which are more complicated to understand and use than VBA) allow objects to define the parameters of children objects through inheritance. VBA doesn’t support this level of object-oriented inheritance, but it is nevertheless a powerful programming environment. The full version of Visual Basic, used to create commercial applications, supports the development of COM components (Active X DLLs and EXEs), which can be used in multiple applications. If you have the Microsoft Office Developer’s version of Microsoft Office, you can create COM Add-Ins for Project in the VB Editor.

Generally, VB is considered a Rapid Application Development (RAD) tool, with which custom solutions can be prototyped, debugged, and built in a much shorter period of time than with other languages. In fact, one of the more common reasons VB is deployed is to provide fast development of database front-end applications. Here are three uses that specifically relate to Project:

  • You can automate forms and data handling, create new data, or access existing data in a project file from another application.

  • You can launch and use other Office applications from within Project.

  • You can customize Project to better meet your needs by creating customized forms and personalized applications.

    Note 

    VBA isn’t exclusive to Microsoft Project; it’s also included with other Microsoft Office programs, including Word, Excel, Access, and PowerPoint. You can use VBA to create programs that work within and between all of the Office applications.

Similar to any programming language, VBA is used to create programs (called projects). A VBA project consists of multiple elements—objects, modules, forms, and references to other documents or templates. Each element contains multiple lines of programming code in the form of statements and procedures. Each statement is a specific instruction that is executed when the entire program is run.

The “Visual” part of Visual Basic for Applications indicates that VBA is a visual programming language, meaning that you don’t actually have to type each line of code by hand. Instead, you can use buttons from a control Toolbox to draw visual elements (such as buttons and lists) on a form; the VBA engine automatically generates the code that creates these objects. In many ways, writing a VBA program—or at least the framework for a program—is as easy as drawing objects in the workspace and then adding code that defines each object’s behavior.

To create a VBA program, you use the Visual Basic Editor (VB Editor). The VB Editor is a program separate from Project that includes the menus, toolbars, and commands necessary to create a full-featured VBA program.

Note 

The VB Editor is also called the Visual Basic Integrated Development Environment (IDE).



Mastering Microsoft Project 2002
Mastering Microsoft Project 2002
ISBN: 0782141471
EAN: 2147483647
Year: 2006
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net