Question

In: Computer Science

Code, pls. Thank you. Exercise - MPG Calculator Create a Windows Forms application and call it...

Code, pls. Thank you.

Exercise - MPG Calculator Create a Windows Forms application and call it MPGCalculator Build a form that looks like the form in the video provided. The form consists of 4 labels, 2 textboxes and 3 buttons Name all controls properly. Certain labels do not have to be named Pay attention to video and set all design time properties accordingly. The "x" should be a hot key for the exit button When Calculate is clicked, you should calculate the MPG and display it. Round to 2 decimal places. (google it!) When Clear is clicked, clear the form. When Exit is clicked, close the form

Solutions

Expert Solution

Below is the solution:

Public Class frmMilesPerGallon
    Private Sub frmMilesPerGallon_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtGallon.Text = ""
        txtMiles.Text = ""
        Label3.Text = "MPG is: "
        label4.Text = "0"
    End Sub

    'Exit Events
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    'calculate button event
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Dim miles As Integer
        Dim gallon As Integer
        Dim mpg As Double

        If (Integer.TryParse(txtMiles.Text, miles) And Integer.TryParse(txtGallon.Text, gallon)) Then 'Accept the miles and gallon integer value
            mpg = miles / gallon 'miles dived by gallon will get the result
            label4.Text = mpg.ToString("0.00")
        Else
            MessageBox.Show("Enter valid value!")
        End If
    End Sub

    'clear button event will clear the all form object value
    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        txtGallon.Clear()
        txtMiles.Clear()
        Label3.Text = "MPG is: "
        label4.Text = "0"
    End Sub
End Class


Related Solutions

Create a windows form application in C# that looks and functions like a basic calculator. It...
Create a windows form application in C# that looks and functions like a basic calculator. It must do the following: Add, subtract, multiply, and divide. Account for division by zero. Show at least two decimal places. Retain the last number on the window so that, when the user opens the calculator the next time, the number that was in the window at the last close appears. Have a memory, so that users can store values and recall them. Operate with...
Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
Using C# Windows App Form Create a simple calculator using +,-,*,/ Please show code GUI Code...
Using C# Windows App Form Create a simple calculator using +,-,*,/ Please show code GUI Code for calculator menus radio button input text boxes
Create code In visual Basic, Windows forms that uses case statements to convert the day of...
Create code In visual Basic, Windows forms that uses case statements to convert the day of the week (entered by the user into an integer. (Sunday = 1, Monday = 2, etc.) For this code, think about error checking. What will your code do if the user enters “dog” for example (which is not a day of the week)? What will your code do if the user enters a number or other incorrect input?
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class named PersonEntry. The PersonEntry class should have properties for a person’s name, e-mail address, and phone number. Also, create a text file that contains the names, e-mail addresses, and phone numbers for at least five people. When the application starts, it should read the data from the file and create a PersonEntry object for each person’s data. The PersonEntry objects should be added to...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might use to represent a character within the game. A character should include six stats as instance variables – strength, dexterity, constitution, intelligence, wisdom and charisma (all types are int). Your class should have a constructor that initializes these six instance variables. Provide Properties with an appropriate set and get block for each instance variable. In addition, provide a method named getStatsTotal that calculates the...
unctional Requirements  Design a Windows Forms Application for a movie database providing appropriate controls for...
unctional Requirements  Design a Windows Forms Application for a movie database providing appropriate controls for the following data:  Movie Name  ISBN13 Number (optional)  Release Date  Location (Canadian OR International)  Genre (Action, Biography, Comedy, Drama, Educational, History, Horror, Musical, Mystery, Romance, Sci-Fi, Thriller OR Western)  Rating (1 to 5 stars)  Duration (in minutes)  Price  Support loading and saving of the data for multiple movies to a Sequential Text file  Display...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls:...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls: A Label control with the following text displayed: "First Number:" A Label control with the following text displayed: "Second Number:" An empty TextField control beside the First Number label. An empty TextField control beside the Second Number label. Five buttons: Button 1 labeled + Button 2 labeled - Button 3 labeled * Button 4 labeled / Button 5 labeled = An empty Label control...
Create a Windows application in C# that can be used to change the form color. Your...
Create a Windows application in C# that can be used to change the form color. Your form background color should initially be blue. Provide at least two buttons with two different color choices and a Reset option. Change the font style and size on buttons. Align the buttons so that they are in the center of the form. The color choice buttons should be the same size. Add event handlers for the buttons so that when the user click the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT