Question: using murach's visual basic 2015 book and visual studio ( need all screenshots and code) Exercise 12-1 Use the debugging tools If you did exercise
using murach's visual basic 2015 book and visual studio
( need all screenshots and code)
Exercise 12-1 Use the debugging tools
If you did exercise 5-2 in chapter 5, youve already set breakpoints, used the Locals window, and stepped through an application. So in this exercise, youll use some of the new skills that were presented in this chapter.
Check out the Debugging options
1. Open the application thats in the C:\VB 2015\Chapter 12\FutureValue directory.
2. Use the DebugOptions command to open the Options dialog box. Then, remove the check mark from the Redirect all Output Window text to the Immediate Window option in the General options.
Use the Edit and Continue feature
3. Run the project with the default entries, and notice that the future value amount is formatted as a percent.
4. End the application and set a breakpoint on the statement in the btnCalculate_Click procedure that calls the procedure that calculates the future value. Then, run the application with the default entries so it enters break mode. In break mode, notice that the statement after the breakpoint uses p instead of c as the formatting code. Correct this code, and press F5 to continue running the application and notice that the formatting is now correct.
5. This illustrates the Edit and Continue feature. Sometimes, though, Visual Studio wont let you change the code in break mode. Then, you can click on the Stop Debugging button, make the change, and restart the application.
Use the Locals windows
6. Click on the Calculate button to enter break mode again, display the Locals window, click on the symbol to the left of the Me keyword, scroll down to txtMonthlyInvestment, and click on its symbol to expand this entry. Then, scroll down to the Text property to see its string value and the Visualizer icon in the Value column.
Use the Visualizer icon to display the value in the Text Visualizer dialog box. Then, close this dialog box, and click on thesymbol to the left of the Me keyword to collapse this entry.
8. Press F11 to step through the statements. Notice the parameters and variables that are displayed in the Locals window at each step. Then, set a second breakpoint on the last statement in the FutureValue procedure (the Return statement), and press F5 to run the application until it enters break mode again. Now, you can see the final values for the calculation.
9. Press F5 to restart the application and display the Future Value form. Click on the Calculate button to start another calculation and enter break mode again. Next, locate the months variable in the Locals window, double-click in the Value column, enter 24, and press the Enter key to change the value. Then, press F5 to continue execution, and notice that 24 is used as the value of the months variable in the future value calculation.
Use the Breakpoints window to disable both breakpoints
10. Display the Breakpoints window and click the Disable All Breakpoints button at the top of the Breakpoints window. This disables both breakpoints without removing them. Then, press F5 to continue execution. Since no breakpoints are enabled, this should display the Future Value form.
11. Click the Exit button to end the program. Then, click the Enable All Breakpoints button in the Breakpoints window to enable both breakpoints, and run the application until it enters break mode at the first breakpoint.
Set a condition for a breakpoint
12. Set a breakpoint on the Next statement in the FutureValue procedure. Then, point to the breakpoint in the margin indicator bar and click on the Settings icon to display the Breakpoint Settings window.
13. Select the Conditions option in the Breakpoint Settings window. Then, choose Hit Count from the first drop-down list, choose Is a multiple of from the second drop-down list, and enter 12 in the text box.
14. Press F5 to continue execution, and notice that the breakpoint is only taken each twelfth time through the loop, or at the end of each year. Continue execution until the form is displayed again, and then click on the Calculate button to start another calculation and enter break mode at the first breakpoint.
Use the Immediate window to work with a variable and a method
15. Display the Immediate window, and display the value of the months variable in this window. Then, display the percentage format of the monthly interest rate by calling the ToString method from the monthlyInterestRate variable like this:
? monthlyInterestRate.ToString("p")
16. Assign a value of 12 to the months variable by entering an assignment statement in the Immediate window. Then, continue running the application so you can see that this value is used in the calculation
Use a Watch window to monitor expressions
17. Use the DebugDelete All Breakpoints command to delete the breakpoints that youve set. Then, set a new breakpoint on the assignment statement in the body of the For loop for the FutureValue procedure.
18. Run the application. When the application enters break mode, display a Watch window, highlight the FutureValue variable, and drag it to that window. Next, drag the index variable to that window and notice that an error is displayed. Thats because the Option Strict option is on.
19. End the application, turn Option Strict off for the project, and run the application one more time with a value of 1 for the years entry. Then, click in the Name column of the first blank row in the Watch window and enter this expression:
i < months
20. Press F11 to step through the For loop and check the values in the Watch window until the value of i < months becomes False.
Use the Output window
21. Use the Console.WriteLine method in the FutureValue procedure to display the values of the i and FutureValue variables each time through the loop. Then, run the application and check the Output window to see how these values are displayed.
22. When youre through experimenting, close the project.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
