CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Posts
    1

    Calculator help?

    Ok, I want to make a calculator, but every example of a calculator is the same "enter two numbers to have them added" or whatever, I want it to be just so i can keep adding numbers until i want to stop, like a real calculator. I don't want exact code I just want to know what I should be looking at.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Calculator help?

    You should create a loop. As long as you don't want to stop, provide input, the function you want to do (+, -, *, /, etc.) and perform the operation. The result you use for the next iteration of the loop. Did you follow?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Apr 2007
    Posts
    39

    Re: Calculator help?

    Your calculator object just needs to have data members representing:
    # last input
    # last operation (ie + - * / )
    # current value
    Then when you hit = it performs the last operation on the last input and the current value and updates current value. That is how a calculator works. Not with a loop.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured