How To Make A Basic Calculator

3

Attached Files

The following files have been attached to this tutorial:

.capx

calculator.capx

Download now 172.24 KB

Stats

2,963 visits, 4,291 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 15 Apr, 2015. Last updated 19 Feb, 2019

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

calculator.capx

Download now 172.24 KB
  • 0 Comments

Want to leave a comment? Login or Register an account!