DOC PREVIEW
PSU METBD 050 - Visual Basic Editor

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

METBD 050Project ExplorerFileMETBD 050 Visual Basic Editor The Visual Basic Editor is used to manage projects and to view the code generated by recording or writing macros. Procedues are created by typing VB code directly into the Code Window of the Visual Basic Editor which is shown in the figure below. The three ways to access the editor are: pick the Visual Basic Editor button from the Visual Basic toolbar, select the menu sequence Tools – Macro - Visual Basic Editor or press Alt-F11. Menu Bar Standard Toolbar Title Bar Properties Window Project Explorer Figure 7: Visual Basic Editor Window Immediate Window Code Window All of the windows within the VB Editor can be moved around in the editor window. They can all be docked in different locations, with the exception of the code window which is undockable. The windows can be turned on or off using the View menu. The common parts of the window are: Project Explorer an organized view of the components of a project Properties Window the place to change and set the attributes of objects Code Window displays VB code, which is written and edited here Immediate Window allows for the execution of individual lines of code and obtaining the value of variables Locals Window displays the value of variables and properties during code execution Object Browser lists all available objects, including their properties, methods and events METBD 050 – VBA Editor.doc Page 1 of 3 3/20/03VB Editor Menu Bar: The menus found on the menu bar can be used to perform most of the development tasks in VBA. A brief explanation of the menus follows: File saving and printing functions for code and forms Edit undo, cut, copy, paste, indent code, clear, select and find View view code, windows and Object Browser Insert insert procedures, forms and new modules Format format form objects Debug tools for debugging or finding errors in a procedure Run run, break or stop the execution of a procedure for testing Tools access project properties and other functionality Window arrange windows within the VB Editor Help access VB help files Code Window: The code for procedures (and recorded macros) is viewed and can be edited in the code window. Individual procedures are separated in the code window by solid gray lines. Every macro begins with the line Sub MacroName and ends with the line End Sub. The code is executed one line at a time from top to bottom. Execution ends when the End Sub line is reached. Procedure View – displays procedures one at a time Full Module View – shows all the procedures in the module Code Window Module Level Declarations Area Procedure list Procedure separators If the code window is not displayed in the VB Editor, right-click on the module in the Project Explorer and select Show Code. METBD 050 – VBA Editor.doc Page 2 of 3 3/20/03Procedures can be executed by placing the cursor within its procedure separators and pressing the F5 key. Pressing the F8 key when the cursor is in the code window activates the Step Into mode of program execution. This method executes one line of code each time the F8 key is pressed. This is a good method to use when debugging procedure code. When you move the focus off of a line of code, the code formatter automatically does the following: • • • • places keywords in proper case adjusts spacing adds punctuation standardizes variable capitalization Text in the code window is automatically formatted by VBA as follows: • • • • • Green = Programmer’s comments used to document what code in the procedure does. Comments are not executed by the computer when the procedure is run. Any line starting with an apostrophe (‘) is treated as a comment. Blue = VBA keywords, such as Sub, End Sub, If, End If, With, and End With. Black = All other text. Editing Guidelines: It is considered good practice to follow the following guidelines when writing code: Indent text within control structures. To do this, select one or more lines of code and press the Tab key. To remove an indent, press Shift-Tab. Complete statements by pressing the Enter key or by clicking somewhere else in the window Include comments about the code by starting the line with an apostrophe (‘). Comments are ignored by the computer during the execution of code. Statements can be carried over to the next line by typing a space and underscore character at the end of the line. This also works for comments. Strings that are carried over to the next line require a closing quote, and ampersand (&), and a space before the underscore. Multiple commands can be placed on a single line if separated by a colon (:). This method is usually harder to follow when reading code. HELP! Within the VB Editor, you can click on words and objects and press the F1 key to access context sensitive help files. Help is also available from the Help menu. METBD 050 – VBA Editor.doc Page 3 of 3


View Full Document

PSU METBD 050 - Visual Basic Editor

Download Visual Basic Editor
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Visual Basic Editor and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Visual Basic Editor 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?