Creating a calculator in visual basic

Assignment Help Software Engineering
Reference no: EM13994674

Creating a calculator in Visual Basic,the instructions given to me by the professor and type the code in the order 

Option Explicit On

Option Strict On

Imports System.Math

 

PublicClassForm1

'declare the golbal variables here

Dim dblResult AsDouble'contains the result of a calculation

 

PrivateSub btnPower_Click(sender AsObject, e AsEventArgs) Handles btnPower.Click

'clear the values of all variables

        resetCalculator()

        dblResult = 0

Me.lblResult.Text = "0"

EndSub

 

PrivateSub Form1_Load(sender AsObject, e AsEventArgs) HandlesMyBase.Load

'clear the values of all variables

PrivateSub resetCalculator()

Me.lblResult.Text = "0"

        dblResult = 0

        strLastMathOperator = "Clear"

        blnStartNewNumber = True

        dblCurrentNumber = 0

EndSub

 

PrivateSub buildNumber() (ByVal strNumber As String)

        lblResult.Text = lblResult.Text & strNumber

        dblCurrentNumber = Convert.ToDouble(lblResult.Text)

'should we start a new number or add to an existing number?

If blnStartNewNumber Then

 

Else

'append to the current number

            lblResult.Text = lblResultResult.Text & strNumber

EndIf

        blnStartNewNumber = False

EndSub

    buildNumber ("2")

    lblResult.Text = lblResult.Text & strNumber

    dblCurrentNumber = Convert.ToDouble(lblResult.Text)

Me.lblResult.Text = ""

 

PrivateSub btn0_Click(sender AsObject, e AsEventArgs) Handles btn0.Click

        buildNumber("0")

EndSub

 

PrivateSub btn1_Click(sender AsObject, e AsEventArgs) Handles btn1.Click

        buildNumber("1")

EndSub

 

PrivateSub btn2_Click(sender AsObject, e AsEventArgs) Handles btn2.Click

        buildNumber("2")

EndSub

 

PrivateSub btn3_Click(sender AsObject, e AsEventArgs) Handles btn3.Click

        buildNumber("3")

EndSub

 

PrivateSub btn4_Click(sender AsObject, e AsEventArgs) Handles btn4.Click

        buildNumber("4")

EndSub

 

PrivateSub btn5_Click(sender AsObject, e AsEventArgs) Handles btn5.Click

        buildNumber("5")

EndSub

 

PrivateSub btn6_Click(sender AsObject, e AsEventArgs) Handles btn6.Click

        buildNumber("6")

EndSub

 

PrivateSub btn7_Click(sender AsObject, e AsEventArgs) Handles btn7.Click

        buildNumber("7")

EndSub

 

PrivateSub btn8_Click(sender AsObject, e AsEventArgs) Handles btn8.Click

        buildNumber("8")

EndSub

 

PrivateSub btn9_Click(sender AsObject, e AsEventArgs) Handles btn9.Click

        buildNumber("9")

EndSub

 

PrivateSub btnSQRT_Click(sender AsObject, e AsEventArgs) Handles btnSQRT.Click

        dblCurrentNumber = Sqrt(dblCurrentNumber)

Me.lblResult.Text = Str(dblCurrentNumber)

EndSub

 

PrivateSub btnPercent_Click(sender AsObject, e AsEventArgs) Handles btnPercent.Click

Me.lblResult.Text = Str(dblCurrentNumber / 100)

        dblCurrentNumber = dblCurrentNumber / 100

        blnStartNewNumber = True

EndSub

 

PrivateSub btnPlusMinus_Click(sender AsObject, e AsEventArgs) Handles btnPlusMinus.Click

        dblCurrentNmber = dblCurrentNumber * (-1)

Me.lblResult.Text = dblCurrentNumber.ToString()

EndSub

'''<summary>

'''Applies the last operator to result using current number

''' </summary>

''' <param name ="strOperation">the math operation to perform +,-,*,/ or clear

''' </param>

''' <remarks><</remarks>

PrivateSub handleOperator(ByVal strOperation AsString)

        handleOperator("Add")

PrivateSub handleOperator(ByVal strOperation AsString)

        strLastMathOperator = strOperation

EndSub

 

SelectCase strLastMathOperator.ToUpper

Case "ADD"

                dblResult = dblResult + dblCurrentNumber

Case "SUBTRACT"

                dblResult = dblResult - dblCurrentNumber

Case "MULTIPLY"

                dblResult = dblResult * dblCurrentNumber

Case "DIVIDE"

                dblResult = dblResult / dblCurrentNumber

CaseElse

             dblResult = dblCurrentNumber

EndSelect

 

    dblCurrentNumber = dblResult

Me.lblResult.Text = dblCurrentNumber.ToString

Me.blnStartNewNumber = True

    btnDecimal.Enabled = True

 

PrivateSub btnDecimal_Click(sender AsObject, e AsEventArgs) Handles btnDecimal.Click

        buildNumber(".")

If blnStartNewNumber Then

            buildNumber("0.")

Else

            buildNumber(".")

EndIf

        btnDecimal.Enabled = False

EndSub

 

PrivateSub btnMemoryAdd_Click(sender AsObject, e AsEventArgs) Handles btnMemoryAdd.Click

        dblMemory = dblMemory + Convert.ToDouble(lblResult.Text)

EndSub

 

PrivateSub btnMemoryClear_Click(sender AsObject, e AsEventArgs) Handles btnMemoryClear.Click

        dblMemory = 0

EndSub

 

PrivateSub btnMemoryRecall_Click(sender AsObject, e AsEventArgs) Handles btnMemoryRecall.Click

        lblResult.Text = dblMemory.ToString

        dblCurrentNumber = dblMemory

EndSub

 

PrivateSub btnMemorySubtract_Click(sender AsObject, e AsEventArgs) Handles btnMemorySubtract.Click

        dblMemory = dblMemory - Convert.ToDouble(lblResult.Text)

EndSub

 

EndClass

Reference no: EM13994674

Questions Cloud

Foreign exchange rates in the wall street journal : In looking at the foreign exchange rates in the Wall Street Journal you notice the dollar-euro spot rate is 1.085€/$ and the six-month forward rate is 1.098€/$. Does this imply that the US dollar is expected to appreciate or depreciate?
Consist of a series of phases : The software life cycle can be said to consist of a series of phases. The classical model is referred to as the waterfall model. Which phase may be defined as "The concept is explored and refined, and the client's requirements are elicited?"
What is the largest resistance you can obtain : Consider connecting three resistors of resistances 31 Ω, 49 Ω, and 695 Ω together. What is the largest resistance you can obtain in Ω? What is the smallest resistance you can obtain in Ω?
Would an increase in european wealth : Would an increase in European wealth, all other factors held constant, cause the dollar to depreciate or appreciate in the foreign exchange market?
Creating a calculator in visual basic : Creating a calculator in Visual Basic,the instructions given to me by the professor and type the code in the order  Option Explicit On Option Strict On
Develop a plan for an event : Develop a plan for an event (e.g., golf tournament; gala ball; annual meeting; or a series of lectures, workshops, or seminars where a fee is charged for attendance or participation) for your organization.
Economic growth and environmental degradation : Historically there has been a close correlation between economic growth and environmental degradation. Is it possible to be sustainable and profitable?
Find the equivalent resistance between point a and b : Find the equivalent resistance between point a and b. If a voltage of 37.9 V is applied between points a and b, find the current in each resistor.
Companys internal corporate marketed department : Your local fast food chain with two dozen stores uses the company's internal corporate marketed department to produce signage, print ads, in-store displays, and so forth. When placing an order, store managers are assessed a chargeback (transfer price..

Reviews

Write a Review

Software Engineering Questions & Answers

  Research report on software design

Write a Research Report on software design and answer diffrent type of questions related to design. Report contain diffrent basic questions related to software design.

  A case study in c to java conversion and extensibility

A Case Study in C to Java Conversion and Extensibility

  Create a structural model

Structural modeling is a different view of the same system that you analyzed from a functional perspective. This model shows how data is organized within the system.

  Write an report on a significant software security

Write an report on a significant software security

  Development of a small software system

Analysis, design and development of a small software system.

  Systems analysis and design requirements

Systems Analysis and Design requirements

  Create a complete limited entry decision table

Create a complete limited entry decision table

  Explain flow boundaries map

Explain flow boundaries map the dfd into a software architecture using transform mapping.

  Frame diagrams

Prepare a frame diagram for the software systems.

  Identified systems and elements of the sap system

Identify computing devices, which could be used to support Your Improved Process

  Design a wireframe prototype

Design a wireframe prototype to meet the needs of the personas and requirements.

  Explain the characteristics of visual studio 2005

Explain the characteristics of Visual Studio 2005.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd