Explore BrainMass

Explore BrainMass

    Enhanced Miles Per Gallon Application

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    (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.

    © BrainMass Inc. brainmass.com October 10, 2019, 6:13 am ad1c9bdddf


    Solution Summary

    An enhanced miles per gallon applications are examined. The closing applications for running applications are given.