Question

In: Computer Science

Please note: This is in Visual Basic. Create an application. Add two text boxes, a label,...

Please note: This is in Visual Basic.

Create an application. Add two text boxes, a label, and a button to the form. The button’s Click event procedure should assign the contents of the text boxes to Double variables named dblNum1 and dblNum2. It then should divide the dblNum1 variable’s value by the dblNum2 variable’s value, assigning the result to a Double variable named dblAnswer. Display the answer in the label. Code the procedure. Save the solution and then start the application. Test the application using the numbers 6 and 2; the number 3 appears in the label control. Now test it using the numbers 6 and 0. The infinity symbol (∞) appears in the label control because the application is trying to divide a number by 0. Add a selection structure to the procedure. The selection structure should perform the division and display the quotient only if the value in the dblNum2 variable is not 0; otherwise, it should display N/A in the label. Save the solution and then start and test the application. Close the solution.

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Windows Forms Application in VB is created using Visual Studio 2017 with name "VBAppDivide".This application contains a form with name "Form1.vb".Below are the files associated with form1.

1.Form1.vb[Design]

2.Form1.vb

'VB class
Public Class Form1
'Divide button click
Private Sub btnDivide_Click(sender As Object, e As EventArgs) Handles btnDivide.Click
'declaring inputs and taking inputs entered by user
Dim dblNum1 As Double = Double.Parse(txtFirstNumber.Text)
'taking second number
Dim dblNum2 As Double = Double.Parse(txtSecondNumber.Text)
'declaring variable to store answer
Dim dblAnswer As Double
dblAnswer = dblNum1 / dblNum2
'using if else checking second number dblNum2
If dblNum2 > 0 Then
'if dblNum2 is not zero then
'display result in the textbox
lblResult.Text = dblAnswer
Else
'otherwise display NA
'display result in the textbox
lblResult.Text = "N/A"
End If

End Sub
End Class

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

Screen 2:Screen when second number is 0

Screen 3:Screen showing division

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

Please note: This is in Visual Basic. Create an application. Add a text box, a label,...
Please note: This is in Visual Basic. Create an application. Add a text box, a label, and a button to the form. If the user enters a number that is greater than 100 in the text box, the button's "click" event procedure should display the result of multiplying the number by 5. Otherwise, it should display the result of dividing the number by 5. Code the procedure.
NOTE: This is done using Visual Basic. Create an application named You Do It 2. Add...
NOTE: This is done using Visual Basic. Create an application named You Do It 2. Add a text box, a label, and a button to the form. Enter the following three Option statements above the Public Class clause in the Code Editor window: Option Explicit On, Option Strict Off, and Option Infer Off. In the button’s Click event procedure, declare a Double variable named dblNum. Use an assignment statement to assign the contents of the text box to the Double...
NOTE: This is done using Visual Basic. Create an application named You Do It 1. Add...
NOTE: This is done using Visual Basic. Create an application named You Do It 1. Add a text box, a label, and a button to the form. The button’s Click event procedure should store the contents of the text box in a Double variable named dblCost. It then should display the variable’s contents in the label. Enter the three Option statements above the Public Class clause in the Code Editor window, and then code the procedure. Save the solution and...
Program on Visual Basic, VBA Create an application that lets the user enter a number of...
Program on Visual Basic, VBA Create an application that lets the user enter a number of seconds and produces output according to the following criteria: There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or...
Visual Basic Your first job is to create a visual basic project that will display the...
Visual Basic Your first job is to create a visual basic project that will display the name and telephone number for the contact person for the customer relations, marketing, order processing, and shipping departments. Include a button for each department. When the user clicks on the button for a department the program(in code for specific button will display the name and telephone number for the contact person in two labels. The same two labels will be used for each department...
Basic Pass Level Requirements - 53 Your extended Text Based Music Application must add the following...
Basic Pass Level Requirements - 53 Your extended Text Based Music Application must add the following functionality: Display a menu that offers the user the following options: 1. Read in Albums 2. Display Albums 3. Select an Album to play 4. Update an existing Album 5. Exit the application Menu option 1 should prompt the user to enter a filename of a file that contains the following information: ·The number of albums ·The first album name ·The first artist name...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
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...
Using Visual Basic 2017, Create a form with two textboxes and one button. A user enters...
Using Visual Basic 2017, Create a form with two textboxes and one button. A user enters the course she is taking in the first text box and then clicks on the button. Then if the user entered "Program Language" in the first text box, the second text box will show "Awesome pick!". If the user entered something else, the text box shows "Ok." Please write the correct code.
Make a Console application Language should be Visual Basic In this assignment, you will be calculating...
Make a Console application Language should be Visual Basic In this assignment, you will be calculating the two parts for each month. you calculate the interest to pay each month and principal you pay every month. The interest you pay every month = loan * monthlyInterest The principal you pay every month = monthlyMortgage -  interest you pay every month ' what is my remaining loan loan = loan - principal you pay every month Problem 1 : Using While Loop,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT