hi there i am doing a work for school and i came up with a problem
i currently have this code:
somar.addEventListener(MouseEvent.CLICK, adicionar);
Subtrair.addEventListener(MouseEvent.CLICK, retirar);
multiplicar.addEventListener(MouseEvent.CLICK, multiplicacao);
Dividir.addEventListener(MouseEvent.CLICK, divisao);
function adicionar (MouseEvent){
var Resultado: Number = Number (caixa1.text) + Number (caixa2.text); caixa3.text = String (Resultado);
}
function retirar (MouseEvent){
var Resultado: Number = Number (caixa1.text) + Number (caixa2.text); caixa3.text = String (Resultado);
}
function divisao (MouseEvent){
var Resultado: Number = Number (caixa1.text) + Number (caixa2.text); caixa3.text = String (Resultado);
}
function multiplicacao (MouseEvent){
var Resultado: Number = Number (caixa1.text) + Number (caixa2.text); caixa3.text = String (Resultado);
}
in short i only can do basic operations like "+", "-", "x" and "/" .... and basically this code above ... will allow me to write the number on the test box 1 and 2 and then i click either one of the operations and the result shows on the last text box.
but ... now comes the tricky part for me, i want to complement my calculator by saying the errors, for example ... when we write on the text box a character and a number, the calculator should show error, and so on, i also wanted to had a button to clear the calculator ... but i have no clue how to do it
i first tried doing a "if else" sequence, but i ended up deleting the code by mistake ... it wasn't working in the first place.
So if there is someone that can help me i would appreciate it
Regards ASilva