单击电源按钮时计算器代码为零 [英] Calculator code to get zero on click of the power button

查看:86
本文介绍了单击电源按钮时计算器代码为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个计算器应用程序,一切正常但我使用了一个电源按钮,我想在点击电源按钮时得到零,之后如果我按下任何数字,它必须给出该特定数字,即0在此之前和之后,如果我将按1,它必须给1而不是01.

I have made an calculator application, everything is working fine but i have used a power button and i want to get zero on clicking the power button and after this if i will press any digit, it must give that particular digit i.e. 0 on on and after this if i will press 1, it must give 1 instead of 01.

推荐答案

这是一个基于Web的桌面应用程序应用程序。 />
您是否需要以这种方式使用电源按钮。当您关闭计算器时会发生什么。



通常,您在加载时将应用程序设置为0,然后在单击新数字时覆盖该值,然后随后的数字会被追加。

要将所有内容都恢复到0,你会有一个通常称为C的单独按钮来清除屏幕。



在任何一种情况下,我都假设你有一个事件处理程序来处理电源按钮按下事件。听起来像初始计算器值没有清除,因此您需要实现该功能。也许你把它保存为一个静态变量....没有代码就不太确定。
Is this is a web based application of a desktop app.
Do you need to use the power button in this manner. What happens when you "power" off the calculator.

Typically you would set the application to 0 on load and then overwrite the value when you click a new digit, then subsequent digits get appended.
To rest everything to 0 you would have a seperate button usually called "C" to clear the screen.

In either case I assume that you have an event handler handling you power button press event. It sounds to me like the initial calculator value is not clearing so you need to implement that functionality. Maybe your saving it as a static variable.... not too sure without code.


在页面加载的后端写swtich case函数
write swtich case function at backend in page load


这篇关于单击电源按钮时计算器代码为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆