Enhanced Miles Per Gallon Application
Not what you're looking for?
(Exercise 13.13) to use exception handling to process the FormatExcepti ons that occur when converting the Stri ngs in the TextBoxes to Doubl es (Fig. 25.16). The original application allowed the user to input the number of miles driven and the number of gallons used for a tank of gas to determine the number of miles the user was able to drive on one gallon of gas.
a) Copying the template to your working directory. Copy the directory C: ExamplesTutori al 25Exerci sesEnhancedMi l esPerGal l on to your C: Si mpl yVB2008 directory.
b) Opening the application's template file. Double click EnhancedMi l esPerGal -
l on. sl n in the EnhancedMi l esPerGal l on directory to open the application.
c) Adding a Try block. Find the cal cul ateMPGButton_Cl i ck event handler. Enclose all of the code in this event handler in a Try block.
d) Adding a Catch block. After the Try block you added in Step c, add a Catch block to handle any FormatExcepti ons that may occur in the Try block. Inside the Catch block, add code to display an error message dialog.
e) Running the application. Select Debug > Start Debugging to run your application.
Enter invalid data, as shown in Fig. 25.16, and click the Calculate MPG Button. A
MessageBox will appear asking you to enter valid input. Enter valid input and click
the Calculate MPG Button again. Verify that the correct output is displayed.
f) Closing the application. Close your running application by clicking its close box.
g) Closing the IDE. Close the Visual Basic IDE by clicking its close box.
Purchase this Solution
Solution Summary
An enhanced miles per gallon applications are examined. The closing applications for running applications are given.
Purchase this Solution
Free BrainMass Quizzes
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
C# variables and classes
This quiz contains questions about C# classes and variables.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.
Basic Networking Questions
This quiz consists of some basic networking questions.
Inserting and deleting in a linked list
This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.