Professional Excel Development [Electronic resources] : The Definitive Guide to Developing Applications Using Microsoft® Excel and VBA® نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional Excel Development [Electronic resources] : The Definitive Guide to Developing Applications Using Microsoft® Excel and VBA® - نسخه متنی

Stephen Bullen, Rob Bovey, John Green

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











Debugging Shortcut Keys that Every Developer Should Know


As with most programming tasks, the fewer times you take your hands off the keyboard during debugging the faster and more productive you will be in the long term. With that in mind, what follows is a list of the most useful debugging-related keyboard shortcuts.

General


F5Run:
Runs the procedure within which the cursor is currently located. If the cursor is not currently located within a procedure that can be run directly, or if the cursor is not located within any procedure, the VBE will prompt you with the Macros dialog, which displays a list of procedures that can be run. If you are already in break mode, F5 will run your code to the next break point or to completion, whichever comes first.

F9Toggle break point:
Toggles between setting and removing a break point on the line of code occupied by the cursor. See the section on Using Break Points above for more details on how to effectively use break points.

Ctrl+Shift+F9Clear all break points:
If you have set a number of break points in your code and then corrected the error you were looking for, you may simply want to remove all break points from your code so that you can run it normally and verify your fix. You can quickly remove all break points from your code by pressing Ctrl+Shift+F9.

Ctrl+GDisplay the Immediate window:
What would be really helpful would be to have a shortcut key, or any simple method for that matter, for clearing the contents of the Immediate window. Unfortunately, no such feature is provided in VBA. In the Tools folder of the accompanying CD we provide a link to a freeware add-in called MZTools that offers this feature along with a host of other useful VBE utilities.

Debug Mode Code Execution


F8Step into:
When in break mode, this key enables you to step through your code one line at a time. If you are not in break mode but your cursor is within a valid entry point procedure, code execution will begin and break mode will start on the first line of that procedure.

Shift+F8Step over:
When in break mode, this will step completely over the next line of code to be executed. Whether that line is a simple statement or a complex nested function call, Shift+F8 will execute all the code required to step over the line and resume break mode at the next breakable position.

Ctrl+Shift+F8Step out of:
If you have stepped into a called procedure and determined that what you are looking for is not there, you don't have to continue single stepping through the rest of the procedure to get back out of it. Ctrl+Shift+F8 will tell VBA to finish executing the procedure you are in and will resume break mode on the first breakable line immediately following the call that brought you into the procedure.

Ctrl+F8Step to cursor:
During debugging, you will often encounter a group of statements that you do not need to examine carefully. Rather than single stepping through them, you can place your cursor at the beginning of the next line of code you would like to step through and press Ctrl+F8. VBA will run all the lines of code between your current position and the point where you placed the cursor, then stop and resume break mode at the line where you placed the cursor.

Ctrl+F9Set next statement:
When you are single-step debugging your code, you may see a section that you would like to skip altogether. To do so, just move the cursor down to the next line you want executed and press Ctrl+F9. VBA will skip all the lines of code between the current execution point and resume break mode on the line specified by your cursor position.

Navigation


Shift+F2Procedure definition:
When you place your cursor within the name of a procedure and press this shortcut, you will be taken to the definition of that procedure.

Ctrl+Shift+F2Last position:
This shortcut is the reverse of Shift+F2. It brings you back to the position within your code where you were when you pressed Shift+F2.

Information


Ctrl+LCall Stack:
This shortcut displays the Call Stack window so you can see how you got to the procedure where you're currently located in a deeply nested section of code.

Shift+F9Quick Watch:
This displays the Quick Watch dialog, which displays the context (scope) of the expression you selected, the expression itself and the value of the expression.

F2Object Browser:
This displays the Object Browser.


/ 225