# How To Make A Basic Calculator

1
• 8 favourites

### Attached Files

The following files have been attached to this tutorial:

.capx

### Stats

1,896 visits, 2,895 views

• Spanish

### Tools

Welcome! I thought about making a tutorial for using mathematical functions, but I know it would be to in-depth for intermediate category, so here is just an overview of the basic functions in a calculator format.

Okay before we start making our calculator, we will need to gather some supplies.

-A new, blank project

-Five buttons

-Two text fields

-One text objects

---------------------------------

Step 1) Create two global variables with a number of 0. name them num1 and num2

Step 2) Name you four buttons in order, Add, Subtract, Multiply, Divide, and Clear.

And from here it is smooth sailing!

Step 3) Position your two text fields side-by-side and and the buttons under, and the text object above them all.

Step 4) Make a new event and make it

Button1(add) > OnClicked >Action< SetValue > and choose num1 and for the amount write this TextField.text

Do the same action within our button1 event, but choose num2 for the variable textfield2.text for the amount.

After all that, also in the button1 event, do

TextObject > SetText > and write int(num1+num2)

.....

That's all the manual work you need, now that you know it. Replicate it for the other three buttons but in order, instead of "+" use "-"(Subtract) "*"(Multiply) "/"(Divide)

____________

And after that you will need to create on more event, and do it for the button5(Clear)

Button5 > OnClicked >Action< TextObject > SetText and for the text,

leave it or change it to ""

------------------------------------

Now run your calculator, and check for errors. As always here's the file!

.CAPX