Chapter 8: Debugging Visual Basic Programs


Chapter 8

Debugging Visual Basic Programs

After completing this chapter, you will be able to:

  • Identify different types of errors in your programs.

  • Use Microsoft Visual Studio debugging tools to set breakpoints and correct mistakes.

  • Use the Autos and Watch windows to examine variables during program execution.

  • Use a visualizer to examine string data types and complex data types within the IDE.

  • Use the Immediate and Command windows to change the value of variables and execute commands in Visual Studio.

In the past few chapters, you've had plenty of opportunity to make programming mistakes in your code. Unlike human conversation, which usually works well despite occasional grammatical mistakes and mispronunciations, communication between a software developer and the Microsoft Visual Basic compiler is successful only when the precise rules and regulations of the Visual Basic programming language are followed.

In this chapter, you'll learn more about the software defects, or bugs, that stop Visual Basic programs from running. You'll learn about the different types of errors that turn up in programs and how to use the Visual Studio debugging tools to detect and correct these defects. What you learn will be useful as you experiment with the programs in this book and when you write longer programs in the future.

Why focus on debugging now? Some programming books skip this topic altogether or place it near the end of the book (after you've learned all the language features of a particular product). There is a certain logic to postponing the discussion, but I think it makes the most sense to master debugging techniques while you learn to program so that detecting and correcting errors becomes part of your standard approach to writing programs and solving problems. At this point in Microsoft Visual Basic 2005 Step by Step, you know just enough about objects, decision structures, and statement syntax to create interesting programs but also enough to get yourself into a little bit of trouble! As you'll soon see, however, Microsoft Visual Studio 2005 makes it easy to uncover your mistakes and get back on the straight and narrow.

Upgrade Notes: Migrating Visual Basic 6 Code to Visual Basic 2005

If you're experienced with Microsoft Visual Basic 6, you'll notice some new features in Microsoft Visual Basic 2005, including the following:

  • Visual Studio includes several new tools for finding and correcting errors. A few of the familiar Visual Basic 6 debugging commands are still a part of Visual Studio (Break All, Step Into, Step Over), but there are also new debugging tools and commands, including revised Standard and Debug toolbars and a menu command that manages exceptions.

  • Several new debugging windows have been added to the Visual Studio IDE, including Autos, Command, Call Stack, Threads, Memory, Script Explorer, Disassembly, and Registers. You won't use these tools for every debugging session, but you might find them useful in more sophisticated applications.

  • In Visual Studio 2005, you can use a new visualizer feature (a magnifying glass icon) to examine the content of complex variables and objects within the IDE, so you can now view HTML, XML, and sophisticated datasets during a debugging session.



Microsoft Visual Basic 2005 Step by Step
Microsoft Visual Basic 2005 Step by Step (Step by Step (Microsoft))
ISBN: B003E7EV06
EAN: N/A
Year: 2003
Pages: 168

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