Question
using murach's visual basic 2015 book and visual studio need screenshots and exe file, and code Exercise 4-1 Modify the Invoice Total application Open the
using murach's visual basic 2015 book and visual studio
need screenshots and exe file, and code
Exercise 4-1 Modify the Invoice Total
application
Open the Invoice Total application
1. Open the application in the C:\VB 2015\Chapter 04\InvoiceTotal directory. This application is almost the same as the one thats presented in figure 4-20, but it uses permissive type semantics and implicit narrowing casts.
2. Test the application with a valid subtotal to verify that the correct discount is being taken. Then, enter a valid subtotal like 225.50 that will yield a discount amount that has more than two decimal places, and make sure that only two decimal places are displayed for the discount amount and total.
Use strict type semantics
3. Stop the test run, and change the type semantics for the project to strict as shown in figure 4-8. Then, review the errors that are now underlined in the code for the Invoice Total form. Note also that a light bulb is displayed when you point to either of these errors, which means that you can use a Quick Actions menu to fix them.
4. If necessary, refer back to figure 3-15 to see how Quick Actions menus work. Then, use the suggestion in the menu for the first error to fix it. This will add a CDec function to your code. Now, display the Quick Actions menu for the second error to see its suggestion, but dont take it. Instead, just add a D after the literal to show the compiler that this is a Decimal value. Now, compile and test to see that this code works.
5. Enter $$1000 for the subtotal and click the Calculate button. This time, an exception should occur, Visual Studio should enter break mode, and the Exception Assistant should display a message that indicates that the input string was not in a correct format. This shows that exceptions still occur, even though youre using strict type semantics.
6. If you like using strict type semantics, turn this option on for all new applications by using the technique in figure 4-8.
Experiment with the code
7. Modify the first statement in the btnCalculate_Click procedure so it uses the Parse method of the Decimal class instead of the CDec function. Then, test the application to verify that it still works the same.
8. Round the values that are stored in the discountAmount and invoiceTotal variables to two decimal places. Then, delete the FormatCurrency functions for these variables and note the errors that this causes. To fix these errors, use the ToString method, not the suggestion from the Quick Actions menu. Then, test the application to make sure that only two decimal places are displayed for the discount amount and total.
9. Save the solution and close it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started