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

  A student enrolls into a programme and the student may

bounix is a higher learning institution that runs several academic programmes. each programme comprises a set of units.

  Describe two major erp systems

Create a 7-to10-slide presentation comparing and contrasting two major ERP systems from different ERP software providers. You may use various sources including the companies' websites

  Write an report on a significant software security report

write an report on a significant software security. report should include details such as for example - the nature of

  Question about test driven development

Suppose you are the project manager for the development of an eCommerce application for a large furniture store. You decide to use TDD in your development procedure.

  Write a one-page report of evolution of computers

Write a one-page report of evolution of computers. MS word document of 1 page, 1 inch border, single line space, font: size 11, black, Times New Roman

  Explain what aspects of project made it successful

What aspects of project made it "successful" in their definition? Would your organization explain this as successful? Explain why or why not?

  Why do so many in-house applications never get finished

Discuss pros and of using automated testing tools. Provide some examples of automated testing tools.

  What information-gathering methods are most appropriate

what information-gathering methods are most appropriate to learn about requirements from reliable's own management staff and other employees? from client health-care organizations? from suppliers?

  Finding example of source code

Discover one example of each label in the following source code and write the line number of the example next to the label.

  Inventory management

Just-in-time(JIT) software is unable to foresee delivery problems resulting from bad weather, labor strikes, etc. Assess how a company using JIT inventory management software should mitigate delivery problems

  How is this model different from other cmms

The five levels are Initial, Repeatable, Defined, Managed, and Optimizing. How is this model different from other CMMs?

  The dfs components

Propose the DFS components that you would consider implementing and configuring based on the needs of the organization. Provide a rationale for your proposal.

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