Introduction To Programming Using Visual Basic (11th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
11th Edition
ISBN: 9780135416037
Author: David I. Schneider
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 3, Problem 1PP

Calculator Write a program that allows the user to specify two numbers and then adds, subtracts, or multiplies them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. See Fig. 3.61. Note: When one of the numbers in an input text box is changed, the output text box should be cleared.

Chapter 3, Problem 1PP, Calculator Write a program that allows the user to specify two numbers and then adds, subtracts, or

Expert Solution & Answer
Check Mark
Program Plan Intro

Implementation of a program to create a calculator which performs addition, subtraction, and multiplication.

Program Plan:

Write a program which creates a calculator having two input text boxes in which the numbers are entered by the user.

The user can click on any of the three buttons of addition, subtraction, and multiplication.

Whichever button is clicked, it’s result will be calculated and displayed on the output textbox.

Program Description Answer

Program Description:

The program works for the creation of a calculator which adds, subtracts, or multiplies the two numbers entered by the user in two separate textboxes and displays the calculation in the output textbox.

There are two textboxes which take input from the user for the first number and the second number.

Three buttons, one for addition, second for subtraction, and the third for multiplication are created.

On clicking the respective buttons, the output textbox will display the calculation.

Explanation of Solution

Program:

Public Class Calculator

'Declare variable.

Dim var2 As Integer

'Declare variable.

Dim var1 As Integer

'Declare variable.

Dim result As Integer

'Create the event for the textbox.

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

'Assign value

var1 = TextBox1.Text

'Assign text to the textbox.

TextBox3.Text = var1

'Ending the function

End Sub

'Create text box event.

Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged

'Assign text to the textbox.

var2 = TextBox2.Text

End Sub

'Create a button click event

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

result = var1 + var2

'Assign text to the textbox.

TextBox3.Text = var1 & "+" & var2 & "=" & result

End Sub

'Create a button click evetn

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

result = var1 - var2

'Assign text to the textbox.

TextBox3.Text = var1 & "-" & var2 & "=" & result

End Sub

'Create a button click event

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

result = var1 * var2

'Assign text to the textbox.

TextBox3.Text = var1 & "*" & var2 & "=" & result

End Sub

End Class

Sample Output

On pressing the addition button:

Introduction To Programming Using Visual Basic (11th Edition), Chapter 3, Problem 1PP , additional homework tip  1

On pressing the subtraction button:

Introduction To Programming Using Visual Basic (11th Edition), Chapter 3, Problem 1PP , additional homework tip  2

On pressing the multiplication button:

Introduction To Programming Using Visual Basic (11th Edition), Chapter 3, Problem 1PP , additional homework tip  3

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Convert Months Write a program that allows the user to enter a whole number of monthsand then converts that amount of time to years and months. See Fig. 3.38. The programshould use both integer division and the Mod operator.
Locate a Letter Write a program that requests a letter, converts it to uppercase, and gives its first position in the sentence “THE QUICK BROWN FOX JUMPS OVER A LAZY DOG.” See Fig. 3.31.
Sort Three Numbers Write a program that requests three different numbers as input and then displays the numbers in order. Use a Procedure named Sort to which the three values are passed ByRef and use a “Swap” procedure similar to the one in Example 3. See Fig. 5.36.

Chapter 3 Solutions

Introduction To Programming Using Visual Basic (11th Edition)

Ch. 3.1 - Prob. 11ECh. 3.1 - Prob. 12ECh. 3.1 - Prob. 13ECh. 3.1 - Prob. 14ECh. 3.1 - Prob. 15ECh. 3.1 - Prob. 16ECh. 3.1 - Prob. 17ECh. 3.1 - Prob. 18ECh. 3.1 - Prob. 19ECh. 3.1 - Prob. 20ECh. 3.1 - Prob. 21ECh. 3.1 - Prob. 22ECh. 3.1 - Prob. 23ECh. 3.1 - Prob. 24ECh. 3.1 - Prob. 25ECh. 3.1 - Prob. 26ECh. 3.1 - Prob. 27ECh. 3.1 - Prob. 28ECh. 3.1 - Prob. 29ECh. 3.1 - Prob. 30ECh. 3.1 - In Exercises 31 and 32, complete the table by...Ch. 3.1 - In Exercises 31 and 32, complete the table by...Ch. 3.1 - Prob. 33ECh. 3.1 - Prob. 34ECh. 3.1 - In Exercises 33 through 40, determine the output...Ch. 3.1 - Prob. 36ECh. 3.1 - Prob. 37ECh. 3.1 - In Exercises 33 through 40, determine the output...Ch. 3.1 - Prob. 39ECh. 3.1 - In Exercises 33 through 40, determine the output...Ch. 3.1 - Prob. 41ECh. 3.1 - In Exercises 41 through 46, identify the...Ch. 3.1 - In Exercises 41 through 46, identify the...Ch. 3.1 - Prob. 44ECh. 3.1 - In Exercises 41 through 46, identify the errors....Ch. 3.1 - In Exercises 41 through 46, identify the...Ch. 3.1 - Prob. 47ECh. 3.1 - Prob. 48ECh. 3.1 - Prob. 49ECh. 3.1 - Prob. 50ECh. 3.1 - Prob. 51ECh. 3.1 - In Exercises 49 through 54, find the value of the...Ch. 3.1 - In Exercises 49 through 54, find the value of the...Ch. 3.1 - In Exercises 49 through 54, find the value of the...Ch. 3.1 - In Exercises 55 through 60, find the value of the...Ch. 3.1 - In Exercises 55 through 60, find the value of the...Ch. 3.1 - Prob. 57ECh. 3.1 - In Exercises 55 through 60, find the value of the...Ch. 3.1 - In Exercises 55 through 60, find the value of the...Ch. 3.1 - In Exercises 55 through 60, find the value of the...Ch. 3.1 - In Exercises 61 through 66, rewrite the statements...Ch. 3.1 - In Exercises 61 through 66, rewrite the statements...Ch. 3.1 - In Exercises 61 through 66, rewrite the statements...Ch. 3.1 - Prob. 64ECh. 3.1 - In Exercises 61 through 66, rewrite the statements...Ch. 3.1 - Prob. 66ECh. 3.1 - Prob. 67ECh. 3.1 - Prob. 68ECh. 3.1 - Prob. 69ECh. 3.1 - Prob. 70ECh. 3.1 - Prob. 71ECh. 3.1 - Prob. 72ECh. 3.1 - Prob. 73ECh. 3.1 - Prob. 74ECh. 3.1 - Prob. 75ECh. 3.1 - Prob. 76ECh. 3.1 - Prob. 77ECh. 3.1 - Prob. 78ECh. 3.1 - Prob. 79ECh. 3.1 - Prob. 80ECh. 3.1 - Prob. 81ECh. 3.1 - Prob. 82ECh. 3.1 - Prob. 83ECh. 3.1 - Prob. 84ECh. 3.1 - Prob. 85ECh. 3.1 - Prob. 86ECh. 3.2 - Prob. 1ECh. 3.2 - Prob. 2ECh. 3.2 - Prob. 3ECh. 3.2 - Prob. 4ECh. 3.2 - Prob. 5ECh. 3.2 - Prob. 6ECh. 3.2 - Prob. 7ECh. 3.2 - Prob. 8ECh. 3.2 - Prob. 9ECh. 3.2 - Prob. 10ECh. 3.2 - Prob. 11ECh. 3.2 - Prob. 12ECh. 3.2 - Prob. 13ECh. 3.2 - In Exercises 1 through 22, determine the output...Ch. 3.2 - Prob. 15ECh. 3.2 - Prob. 16ECh. 3.2 - Prob. 17ECh. 3.2 - Prob. 18ECh. 3.2 - Prob. 19ECh. 3.2 - Prob. 20ECh. 3.2 - Prob. 21ECh. 3.2 - In Exercises 1 through 22, determine the output...Ch. 3.2 - Prob. 23ECh. 3.2 - Prob. 24ECh. 3.2 - (True or False) If is the length of str, then is...Ch. 3.2 - (True or False) If n is the length of str, then ...Ch. 3.2 - Prob. 27ECh. 3.2 - Prob. 28ECh. 3.2 - Prob. 29ECh. 3.2 - Prob. 30ECh. 3.2 - Prob. 31ECh. 3.2 - Prob. 32ECh. 3.2 - Prob. 33ECh. 3.2 - In Exercises 27 through 34, identify any errors....Ch. 3.2 - Prob. 35ECh. 3.2 - Prob. 36ECh. 3.2 - Prob. 37ECh. 3.2 - Prob. 38ECh. 3.2 - Prob. 39ECh. 3.2 - Prob. 40ECh. 3.2 - Prob. 41ECh. 3.2 - In Exercises 39 through 44, write a program to...Ch. 3.2 - Prob. 43ECh. 3.2 - Prob. 44ECh. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - Prob. 56ECh. 3.2 - Prob. 57ECh. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.2 - In the following exercises, write a program to...Ch. 3.3 - Prob. 1ECh. 3.3 - Prob. 2ECh. 3.3 - Prob. 3ECh. 3.3 - Prob. 4ECh. 3.3 - Prob. 5ECh. 3.3 - Prob. 6ECh. 3.3 - Prob. 7ECh. 3.3 - Prob. 8ECh. 3.3 - Prob. 9ECh. 3.3 - Prob. 10ECh. 3.3 - Prob. 11ECh. 3.3 - Prob. 12ECh. 3.3 - Prob. 13ECh. 3.3 - Prob. 14ECh. 3.3 - Prob. 15ECh. 3.3 - Prob. 16ECh. 3.3 - Prob. 17ECh. 3.3 - Prob. 18ECh. 3.3 - Prob. 19ECh. 3.3 - Prob. 20ECh. 3.3 - Prob. 21ECh. 3.3 - Prob. 22ECh. 3.3 - Prob. 23ECh. 3.3 - Prob. 24ECh. 3.3 - Prob. 25ECh. 3.3 - Prob. 26ECh. 3.3 - In Exercises 1 through 52, determine the output...Ch. 3.3 - Prob. 28ECh. 3.3 - Prob. 29ECh. 3.3 - Prob. 30ECh. 3.3 - Prob. 31ECh. 3.3 - Prob. 32ECh. 3.3 - Prob. 33ECh. 3.3 - Prob. 34ECh. 3.3 - Prob. 35ECh. 3.3 - Prob. 36ECh. 3.3 - Prob. 37ECh. 3.3 - Prob. 38ECh. 3.3 - In Exercises 1 through 52, determine the output...Ch. 3.3 - Prob. 40ECh. 3.3 - Prob. 41ECh. 3.3 - Prob. 42ECh. 3.3 - Prob. 43ECh. 3.3 - Prob. 44ECh. 3.3 - In Exercises 1 through 52, determine the output...Ch. 3.3 - Prob. 46ECh. 3.3 - Prob. 47ECh. 3.3 - Prob. 48ECh. 3.3 - In Exercises 1 through 52, determine the output...Ch. 3.3 - In Exercises 1 through 52, determine the output...Ch. 3.3 - Prob. 51ECh. 3.3 - Prob. 52ECh. 3.3 - In Exercises 53 through 56, determine the output...Ch. 3.3 - In Exercises 53 through 56, determine the output...Ch. 3.3 - Prob. 55ECh. 3.3 - In Exercises 53 through 56, determine the output...Ch. 3.3 - In Exercises 57 through 64, identify any errors....Ch. 3.3 - Prob. 58ECh. 3.3 - In Exercises 57 through 64, identify any...Ch. 3.3 - Prob. 60ECh. 3.3 - Prob. 61ECh. 3.3 - Prob. 62ECh. 3.3 - Prob. 63ECh. 3.3 - Prob. 64ECh. 3.3 - Prob. 65ECh. 3.3 - Prob. 66ECh. 3.3 - Prob. 67ECh. 3.3 - Prob. 68ECh. 3.3 - Prob. 69ECh. 3.3 - Prob. 70ECh. 3.3 - Prob. 71ECh. 3.3 - In Exercises 71 and 72, write a statement to carry...Ch. 3.3 - Prob. 73ECh. 3.3 - Prob. 74ECh. 3.3 - Prob. 75ECh. 3.3 - Prob. 76ECh. 3.3 - Prob. 77ECh. 3.3 - Prob. 78ECh. 3.3 - Prob. 79ECh. 3.3 - Prob. 80ECh. 3.3 - Prob. 81ECh. 3.3 - Prob. 82ECh. 3.3 - Prob. 83ECh. 3.3 - How Old Would You Be on Mercury? The length of a...Ch. 3.3 - Change in Salary A common misconception is that if...Ch. 3.3 - Prob. 86ECh. 3.3 - Prob. 87ECh. 3.3 - Marketing Terms The markup of an item is the...Ch. 3 - Calculator Write a program that allows the user to...Ch. 3 - Repair Bill Suppose automobile repair customers...Ch. 3 - Prob. 3PPCh. 3 - Length Conversion Write a program to convert a...Ch. 3 - Car Loan If A dollars are borrowed at r interest...Ch. 3 - Prob. 6PPCh. 3 - Bond Yield One measure of a bond's performance is...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY