Calculator program

juggernot

Well-known member
Joined
Sep 28, 2006
Messages
173
Programming Experience
Beginner
I'd like to make a calculator program (yes I know every computer already has one). It's just basically so I can learn more code and become a better programmer. To make a decent calculator program is probably far beyond my skills. Could anyone help me out with this? I know how to change the text of a label when a button is pressed, but i don't know how to add on to it. Let me be more clear, If the user presses 1, than +, then 2, I need the label to show that as [1 + 2]. The simplest way to do this would be if there was code that would simply take the text in the label, and treat it as an equation.

Then I need to somehow calculate the answer. I won't be able to do this the normal way, because the textbox has two seperate values in it that I need to take into account. There is probably a way to do this but I can't figure it out.

Also, I'll probably run into difficulty when creating a question that has more parts. Example : 3-9*5+8

I realize that my original program will be missing plenty of things like Sin, Tan Cos, Brackets, etc.
 
I wouldn't recommend a beginner programmer attempting to create a calculator. Especially not one interpreting free expressions typed in by users.
 
Hello juggernot. You carry on with your enterprise. Even if you do not get to the perfect calculator you seek, you will, along the way, learn a lot. Building a calculator (of sorts) is part of a Microsoft course in the early stages.
Best Of Luck.

One cannot control the winds, but one can adjust the sails.
 
I wouldn't recommend a beginner programmer attempting to create a calculator. Especially not one interpreting free expressions typed in by users.

Well, it depends JohnH. I have found that I tend to learn things much faster and in more detail by creating applications which is fairly above average in difficulty than those which are just plain easy and boring.

In any case, the easiest and most suitable way (in my opinion) would be to use a collection to store data, thus you could just add more when needed, and with a little bit of coding, you could even add things such as removing values either from the start, end or middle of the list.

Also, using a list could have you create a personlised structure and use that within the type of the list.

So, have a look at the Collections namespace. That will be (again in my opinion) the best way to go.

Kind regards,
MalloC
 
Back
Top