1 回答

TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個(gè)贊
可以實(shí)現(xiàn)復(fù)雜運(yùn)算
private void calc(){
switch(strOper){
case "+":
dblAcc+=dblSec;//加法運(yùn)算 break; case "-":
dblAcc-=dblSec;//減法運(yùn)算 break; case "*":
dblAcc*=dblSec;//乘法運(yùn)算 break; case "/":
dblAcc/=dblSec;//除法運(yùn)算 break;}strOper="=";//等號運(yùn)算
blnFrstOpen=true;
txtCalc.Text=Convert.ToString(dblAcc);//將運(yùn)算結(jié)果轉(zhuǎn)換成字符型,并輸出結(jié)果
dblSec=dblAcc;}小數(shù)點(diǎn)運(yùn)算//先判斷是否已經(jīng)按了小數(shù)點(diǎn)按鈕,如果按了,最0.x來代替運(yùn)算變量,并且將轉(zhuǎn)換成Double數(shù)型數(shù)值
private void btn_clk(object obj,EventArgs ea){
if(blnClear)
txtCalc.Text="";
Button b3=(Button)obj;
txtCalc.Text+=b3.Text;
if(txtCalc.Text==".")
txtCalc.Text="0.";
- 1 回答
- 0 關(guān)注
- 1082 瀏覽
添加回答
舉報(bào)