1 / 18

Debugging Code in Visual Basic

Debugging Code in Visual Basic. Overview. Types of Errors Debugging Terms Debugging Code in Visual Basic Using the Call Stack Using Watch Variables to Monitor Program Execution Using the Locals Window. Types of Errors. Programming errors generally fall into 3 areas: Syntax Run-Time

Patman
Download Presentation

Debugging Code in Visual Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Debugging Code in Visual Basic

  2. Overview • Types of Errors • Debugging Terms • Debugging Code in Visual Basic • Using the Call Stack • Using Watch Variables to Monitor Program Execution • Using the Locals Window

  3. Types of Errors Programming errors generally fall into 3 areas: • Syntax • Run-Time • Logic

  4. Debugging Terms • Break Mode vs. Run Mode • Watch Expressions • Watch Point Variables • Debug Windows

  5. Run Mode vs. Break Mode • Run mode is like “Run”. The application is executing. F5 is the shortcut to execute your code. • Break Mode is like “Pause”. Visual Basic will enter Break Mode when: • The program hits a manual break point (F9 is the toggle key) • The program hits a Stop statement • A watch is triggered • Ctrl-Break (especially nice for endless loops!) • A run-time error occurs and the Debug option is chosen.

  6. What can you do in Break Mode? What can’t you do? When in Break mode you can: • Modify the application code • Check variables • Change values • Change the program flow • Execute Visual Basic statements, functions

  7. Setting BreakPoint • Manual toggle F9 or • Put in a stop • Using a Debug.Assert Statement You can conditionally enter Break mode using the Debug.Assert method. This method uses a Boolean expression to determine where or not to enter Break mode:Debug.Assert BooleanExpression Note: Asserts only work within the development environment.

  8. Watch Expressions What’s a Watch?Hint: It’s not a Timex. A watch allows you to : • Monitor the behavior of a variable or expression as the program executes. • Under certain conditions a Watch can kick you into Break mode, for example when a particular value changes or becomes True. Watch Expressions are viewed in the Watch Window.

  9. Watch Window

  10. Quick Watch (Shift + F9)

  11. Using the Immediate Window What’s in the Variable? • ? Variable This will print out the value contained by the variable. Example ? Me.Name I don’t want that value, I want THAT value • Variable = Value This will set the variable to be a specific value. Example: strHolder = “Kilroy was Here” intHolder = 100

  12. Immediate Window (Ctrl + G)

  13. Local Window • Local Window is everything on steroids

  14. Call Stack (Ctrl + L) • How did I get Here?

  15. Debugging Toolbar “Window” Buttons Locals Window Immediate Window Watch Window Add Quick watch Call Stack Window “Flow” Buttons Breakpoint toggle Step Into Step Over Step Out “Action” Buttons Run Pause Stop

  16. Debugging Menu

  17. Summary • Types of Errors • Debugging Terms • Debugging Windows • Debugging Code in Visual Basic • Using the Call Tree • Using Watch Variables to Monitor Program Execution

  18. Useful Web Sites • Beginning VB http://groups.msn.com/NTPCUGDevToolsSIG • Advanced VBhttp://rsj-services.com/ntpcug/ • Developer Issues http://members.tripod.com/appdevissues/ • Accesshttp://members.tripod.com/ntaccess/ • Microsoft Developer SIGShttp://ntmsdevsigs.homestead.com/ • North Texas PC Users Grouphttp://www.ntpcug.org/

More Related