26 02 CYU3DUNZZNWCJCQXGZPHLK35372ARPGGLFKAYPY




Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!:Debugging And Distributing Your Applications
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6! (Publisher: The Coriolis Group) Author(s): Peter G. Aitken ISBN: 1576102815 Publication Date: 08/01/98 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




While your program is paused at a breakpoint, you have the following execution commands available to you. They are located on the Run menu, represented by toolbar buttons:


•  Continue—Resumes program execution with the next statement.
•  End—Terminates program execution.
•  Restart—Restarts the program. Selecting Restart has the same effect as selecting End followed by Run.

While a program is paused, you can track down bugs in a number of different ways. These are covered in the following sections.

Using Watch Expressions
A watch expression is a Basic expression whose value is monitored, or watched, during program debugging. A watch expression can be any Basic expression—a program variable, an object property, a function call, or a combination of these elements. You can use any of Visual Basic’s mathematical and logical operators, as well as its built-in functions, to create a watch expression. As mentioned earlier, a prime cause of program bugs is a program variable or property taking on an inappropriate value. By setting a watch, you can keep an eye on the value of the variable or property to see if and when it changes.
You can use a watch expression in several ways:

•  You can monitor its value. Visual Basic will display the expression value in the Watches window, which opens automatically when you define a watch expression. The displayed value is updated whenever the program enters break mode.
•  You can specify that the program pause (enter break mode) whenever the value of the expression changes.
•  You can specify that the program enter break mode whenever the value of the expression becomes True.

To set a watch expression, select Add Watch from the Debug menu. Visual Basic will open the Add Watch dialog box, which is shown in Figure 26.1. If the editing cursor is on the name of a variable or property at the time you display the dialog box, the variable or property name will automatically be entered in the Expression box in the Add Watch dialog box (as is Total in the figure). Also, if you first select a Basic code expression, then the selected code will be entered here.

Next, you will need to enter or edit the desired watch expression in the Expression box—unless, of course, the desired expression was entered automatically. Finally, select the desired type of watch in the Watch Type section of the dialog box, then click on OK. (The Context setting in the Add Watch dialog box will be explained later.)
When you add a watch—no matter what type it is—it will be displayed in the Watches window, as shown in Figure 26.2. Each watch expression is displayed on its own line. The icon at the left end of the line identifies the type of watch (watch, break when changes, or break when True). When you first add items to the Watches window (also shown in Figure 26.2), the Value column displays <Out of context>, and the Type column displays Empty. These will change when the program executes.

Figure 26.1  The Add Watch dialog box.


Figure 26.2  The Watches window after adding several watches, but before executing the program.

Let’s look at some watch expression examples. Table 26.1 lists the purpose, type, and expression for a variety of debugging situations.

When you execute a program where watches are set, every time the program breaks, the information displayed in the Watches window is updated. This occurs regardless of whether the break was caused by a breakpoint set on a line of code or by a Break When Value Changes or Break When Value Is True watch expression. Then, the Watches window displays the following:

•  Value—The current value of the expression or <Out of context> (I will explain this soon).
•  Type—The data type of the expression—Single, Double, Integer, etc.

Working In The Watches Window
While the program is in break mode, you can do several things in the Watches window to assist your debugging. Right-click on any watch expression to display the shortcut menu shown in Figure 26.3. Your choices are:


Table 26.1 Sample watch expressions.



Purpose
Type Of Watch
Watch Expression

To monitor the value stored in the string variable Name
Watch Expression
Name

To monitor the length of the text stored in Name
Watch Expression
Len(Name) Note: Len is one of Visual Basic’s built-in functions

To break when X is less than 0
Break when Value is True
X < 0

To break when the Text property of the Text Box named Data1 changes
Break when Value Changes
Data1.Text

To break when the Text Box named Data1 is blank
Break When Value is True
Data1.Text = “” or Len(Data1.Text) = 0




•  Edit Watch—Opens the Edit Watch dialog box to make changes to the specified watch expression.
•  Add—Opens the Add Watch dialog box to add a new watch expression to the Watches window.
•  Delete—Deletes the selected watch expression.
•  Continue—Continues program execution (equivalent to pressing F5 or clicking on the Continue button on the toolbar).
•  End—Ends program execution (equivalent to clicking on the End button on the toolbar).

You can also modify the value of variables in the Watches window. Click on any watch expression once to highlight it, then click on the value displayed in the Value column. You can now edit the displayed value. When you move off the line by clicking on another expression or pressing the up or down arrow key, the variable takes on the value you entered. This value will remain in effect when you continue program execution. You’ll find this technique useful for testing the effects that different variable values will have on the program execution.




Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.



Wyszukiwarka

Podobne podstrony:
KPC Wykład (17) 26 02 2013
26 02 08 sem II
26 02 08 sem II
26 02 07
Wprowadzenie do GIS wykład 26 02 2013
Geo fiz wykład 26 02 2013
wyklad w dniu 26 02 2010
2011 02 26 klasa O
2005 02 26
TI 02 10 26 T pl(1)
2011 02 26 IV liga
TI 02 08 26 T pl
02 Biesaga T Uzasadnienie norm w bioetyce MP 6 2004 s 23 26
MB zadania 2010 02 26
2607PYRZ M 11 01 02 WYKOPY POD FUNDAMENTY

więcej podobnych podstron