Question: using murach's visual basic 2015 and visual studio need screen shots, code and exe file Exercise 3-1 application event handler procedure declaration procedure name completion
using murach's visual basic 2015 and visual studio
need screen shots, code and exe file
Exercise 3-1
application event handler procedure declaration procedure name completion list tool tip line-continuation character comment syntax error build error comment out a line bookmark collapse expand code snippet identifier
refactoring live code analysis inline renaming quick action annotation bar mode map mode My feature build a project run a project test a project runtime error exception bug debug break mode data tip
Code the Invoice Total form
In this exercise, youll add code to the Invoice Total form that you designed in exercise 2-1. Then, youll build and test the project to be sure it works. Youll also experiment with debugging and review some help information.
Copy and open the Invoice Total application
1. Use the Windows Explorer to copy the Invoice Total project that you created for chapter 2 from the C:\VB 2015\Chapter 02 directory to the C:\VB 2015\ Chapter 03 directory.
2. Open the Invoice Total solution (InvoiceTotal.sln) thats now in the C:\VB 2015\Chapter 03\InvoiceTotal directory.
.
Add code to the form and correct syntax errors
3. Display the Invoice Total form in the Form Designer, and double-click on the Calculate button to open the Code Editor and generate the procedure declaration for the Click event of this object. Then, enter the code for this procedure as shown in figure 3-7. As you enter the code, be sure to take advantage of all of the Visual Studio features for coding including snippets.
4. Return to the Form Designer, and double-click on the Exit button to generate the procedure declaration for the Click event of this object. Enter the state- ment shown in figure 3-7 for this event handler.
5. Open the Error List window as described in figure 3-10. If any syntax errors are listed in this window, double-click on each error to move to the error in the Code Editor. If the Quick Actions feature is available for an error, check to see whether its suggested correction (or one of its suggested corrections) is the one you want to make. Then, correct the error.
Test the application
6. Press F5 to build and run the project. If any syntax errors are detected, youll need to correct the errors and press F5 again.
7. When the application runs and the Invoice Total form is displayed, enter a valid numeric value in the first text box and click the Calculate button or press the Enter key to activate this button. Assuming that the calculation works, click the Exit button or press the Esc key to end the application. If either of these procedures doesnt work right, of course, you need to debug the problems and test the application again.
Enter invalid data and display data tips in break mode
8. Start the application again. This time, enter xx for the subtotal. Then, click the Calculate button. This will cause Visual Studio to enter break mode and display the Exception Assistant.
9. Note the highlighted statement and read the message thats displayed in the Exception Assistant. Then, close the Assistant, and move the mouse pointer over the property in this statement to display its data tip. This shows that the code for this application needs to be enhanced so it checks for invalid data.
10. Click the drop-down arrow in the data tip and select Text Visualizer. This shows the data exactly as it was entered in the Text Visualizer dialog box. Then, click the Stop Debugging button in the Standard toolbar to end the application.
Experiment with the Visual Studio features
11. Right-click on the name of the discountPercent variable and select the Rename command from the shortcut menu thats displayed. When the Rename dialog box appears, enter the name discountPct and notice that all occurrences of the variable are changed.
12. If the Preview Changes option in the Rename dialog box is selected, deselect it. Then, click the Apply button or press the Enter key to apply the changes. Now, run the form to make sure it still works correctly.
13. Select the lines that contain the ElseIf clauses and click on the Comment Out button in the Standard toolbar. Then, run the application to see how it works when these lines are ignored. When youre done, select the lines that were commented out and click on the Uncomment button to restore them.
14. In the Code Editor, click on the minus sign in front of the btnCalculate_Click procedure to collapse it. Then, expand that procedure again so you can see its code.
15. Click on the If keyword in the btnCalculate_Click procedure, and notice that this keyword, along with the Then, ElseIf, Else, and End If keywords are highlighted. Then, click on any occurrence of txtSubtotal to see that all occurrences are highlighted.
16. If your mouse has a scroll wheel, hold down the Ctrl key and scroll the wheel forward to zoom into the code in the Code Editor window. Then, scroll it backward to zoom back out.
17. In the Solution Explorer, show all the files and double-click on the file named frmInvoiceTotal.Designer.vb to open it in the Code Editor. This is the code that determines how the form will look when its instantiated. After you read chapter 11 and section 4, this code will make more sense to you. For now, though, just close the window with this code.
Experiment with the Help feature
18. To see how context-sensitive help works, place the insertion point in the Select method in the last statement of the first event handler and press F1. This should open online help in your default browser and display a topic that tells you more about this method.
19. Click the magnifying glass at the top of the window, type quick actions into the Search text box, and then press the Enter key to see the entries that are listed in the center pane. Click on the Perform quick actions with light bulbs topic to display it.
20. Click the last link in the right pane to jump to that part of the topic. Then, click on one or more topics in the table of contents to display them.
Exit from Visual Studio
21. Click the Close button for the Visual Studio window to exit from this application. If you did everything and got your application to work right, youve come a long way!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
