




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
第C#實現(xiàn)簡易計算器功能(2)(窗體應(yīng)用)number1=number1*10+an;
labelout.Text=Convert.ToString(number1);
}
else
{
number2=number2*10+an;
labelout.Text=Convert.ToString(number2);
}
}
privatevoidplus_Click(objectsender,EventArgse)
{
mode=Operator.plus;
switchmode();
//isequal=true;
}
privatevoidminus_Click(objectsender,EventArgse)
{
mode=Operator.minus;
switchmode();
}
privatevoidmultiplication_Click(objectsender,EventArgse)
{
mode=Operator.multiplication;
switchmode();
}
privatevoiddivision_Click(objectsender,EventArgse)
{
mode=Operator.division;
switchmode();
}
privatevoidequal_Click(objectsender,EventArgse)
{
switch(mode)
{
caseOperator.plus:
result=number1+number2;
break;
caseOperator.minus:
result=number1-number2;
break;
caseOperator.multiplication:
result=number1*number2;
break;
caseOperator.division:
result=number1/number2;
break;
}
isequal=true;
labelbefore.Text="";
labelmode.Text="";
labelout.Text=Convert.ToString(result);
}
publicvoidcleanAll()
{
number1=0;
number2=0;
labelout.Text=Convert.ToString(number1);
labelbefore.Text="";
labelmode.Text="";
isequal=false;
mode=Operator.none;
}
publicvoidswitchmode()
{
switch(mode)
{
caseOperator.plus:
labelmode.Text="+";
break;
caseOperator.minus:
labelmode.Text="-";
break;
caseOperator.multiplication:
labelmode.Text="*";
break;
caseOperator.division:
labelmode.Text="/";
break;
}
//isequal=true;
//cleanAll();
labelbefore.Text=Convert.ToString(number1);
labelout.Text=Convert.ToString(number2);
}
}
}
namespaceWindowsFormsAppCalculator
partialclassForm1
{
///summary
///必需的設(shè)計器變量。
////summary
privateSystem.ComponentModel.IContainercomponents=null;
///summary
///清理所有正在使用的資源。
////summary
///paramname="disposing"如果應(yīng)釋放托管資源,為true;否則為false。/param
protectedoverridevoidDispose(booldisposing)
{
if(disposing(components!=null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#regionWindows窗體設(shè)計器生成的代碼
///summary
///設(shè)計器支持所需的方法-不要修改
///使用代碼編輯器修改此方法的內(nèi)容。
////summary
privatevoidInitializeComponent()
{
this.labelout=newSystem.Windows.Forms.Label();
this.labelbefore=newSystem.Windows.Forms.Label();
this.labelmode=newSystem.Windows.Forms.Label();
this.num1=newSystem.Windows.Forms.Button();
this.num6=newSystem.Windows.Forms.Button();
this.num8=newSystem.Windows.Forms.Button();
this.num7=newSystem.Windows.Forms.Button();
this.num5=newSystem.Windows.Forms.Button();
this.num4=newSystem.Windows.Forms.Button();
this.num9=newSystem.Windows.Forms.Button();
this.num2=newSystem.Windows.Forms.Button();
this.num3=newSystem.Windows.Forms.Button();
this.num0=newSystem.Windows.Forms.Button();
this.clean=newSystem.Windows.Forms.Button();
this.minus=newSystem.Windows.Forms.Button();
this.multiplication=newSystem.Windows.Forms.Button();
this.division=newSystem.Windows.Forms.Button();
this.plus=newSystem.Windows.Forms.Button();
this.equal=newSystem.Windows.Forms.Button();
this.SuspendLayout();
//
//labelout
//
this.labelout.Font=newSystem.Drawing.Font("宋體",25.8F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(134)));
this.labelout.Location=newSystem.Drawing.Point(26,111);
this.labelout.Name="labelout";
this.labelout.Size=newSystem.Drawing.Size(463,49);
this.labelout.TabIndex=0;
this.labelout.TextAlign=System.Drawing.ContentAlignment.BottomRight;
//
//labelbefore
//
this.labelbefore.Font=newSystem.Drawing.Font("宋體",22.2F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(134)));
this.labelbefore.Location=newSystem.Drawing.Point(27,9);
this.labelbefore.Name="labelbefore";
this.labelbefore.Size=newSystem.Drawing.Size(463,43);
this.labelbefore.TabIndex=1;
this.labelbefore.TextAlign=System.Drawing.ContentAlignment.BottomRight;
//
//labelmode
//
this.labelmode.Font=newSystem.Drawing.Font("宋體",22.2F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(134)));
this.labelmode.Location=newSystem.Drawing.Point(28,61);
this.labelmode.Name="labelmode";
this.labelmode.Size=newSystem.Drawing.Size(463,39);
this.labelmode.TabIndex=2;
this.labelmode.TextAlign=System.Drawing.ContentAlignment.BottomRight;
//
//num1
//
this.num1.Location=newSystem.Drawing.Point(35,199);
this.num1.Name="num1";
this.num1.Size=newSystem.Drawing.Size(71,41);
this.num1.TabIndex=3;
this.num1.Text="1";
this.num1.UseVisualStyleBackColor=true;
this.num1.Click+=newSystem.EventHandler(this.num1_Click);
//
//num6
//
this.num6.Location=newSystem.Drawing.Point(218,253);
this.num6.Name="num6";
this.num6.Size=newSystem.Drawing.Size(71,41);
this.num6.TabIndex=6;
this.num6.Text="6";
this.num6.UseVisualStyleBackColor=true;
this.num6.Click+=newSystem.EventHandler(this.num6_Click);
//
//num8
//
this.num8.Location=newSystem.Drawing.Point(130,312);
this.num8.Name="num8";
this.num8.Size=newSystem.Drawing.Size(71,41);
this.num8.TabIndex=7;
this.num8.Text="8";
this.num8.UseVisualStyleBackColor=true;
this.num8.Click+=newSystem.EventHandler(this.num8_Click);
//
//num7
//
this.num7.Location=newSystem.Drawing.Point(35,312);
this.num7.Name="num7";
this.num7.Size=newSystem.Drawing.Size(71,41);
this.num7.TabIndex=8;
this.num7.Text="7";
this.num7.UseVisualStyleBackColor=true;
this.num7.Click+=newSystem.EventHandler(this.num7_Click);
//
//num5
//
this.num5.Location=newSystem.Drawing.Point(130,253);
this.num5.Name="num5";
this.num5.Size=newSystem.Drawing.Size(71,41);
this.num5.TabIndex=9;
this.num5.Text="5";
this.num5.UseVisualStyleBackColor=true;
this.num5.Click+=newSystem.EventHandler(this.num5_Click);
//
//num4
//
this.num4.Location=newSystem.Drawing.Point(35,253);
this.num4.Name="num4";
this.num4.Size=newSystem.Drawing.Size(71,41);
this.num4.TabIndex=10;
this.num4.Text="4";
this.num4.UseVisualStyleBackColor=true;
this.num4.Click+=newSystem.EventHandler(this.num4_Click);
//
//num9
//
this.num9.Location=newSystem.Drawing.Point(218,312);
this.num9.Name="num9";
this.num9.Size=newSystem.Drawing.Size(71,41);
this.num9.TabIndex=11;
this.num9.Text="9";
this.num9.UseVisualStyleBackColor=true;
this.num9.Click+=newSystem.EventHandler(this.num9_Click);
//
//num2
//
this.num2.Location=newSystem.Drawing.Point(130,199);
this.num2.Name="num2";
this.num2.Size=newSystem.Drawing.Size(71,41);
this.num2.TabIndex=12;
this.num2.Text="2";
this.num2.UseVisualStyleBackColor=true;
this.num2.Click+=newSystem.EventHandler(this.num2_Click);
//
//num3
//
this.num3.Location=newSystem.Drawing.Point(218,199);
this.num3.Name="num3";
this.num3.Size=newSystem.Drawing.Size(71,41);
this.num3.TabIndex=13;
this.num3.Text="3";
this.num3.UseVisualStyleBackColor=true;
this.num3.Click+=newSystem.EventHandler(this.num3_Click);
//
//num0
//
this.num0.Location=newSystem.Drawing.Point(130,372);
this.num0.Name="num0";
this.num0.Size=newSystem.Drawing.Size(71,41);
this.num0.TabIndex=14;
this.num0.Text="0";
this.num0.UseVisualStyleBackColor=true;
this.num0.Click+=newSystem.EventHandler(this.num0_Click);
//
//clean
//
this.clean.Location=newSystem.Drawing.Point(387,199);
this.clean.Name="clean";
this.clean.Size=newSystem.Drawing.Size(71,41);
this.clean.TabIndex=15;
this.clean.Text="清除";
this.clean.UseVisualStyleBackColor=true;
this.clean.Click+=newSystem.EventHandler(this.clean_Click);
//
//minus
//
this.minus.Location=newSystem.Drawing.Point(305,253);
this.minus.Name="minus";
this.minus.Size=newSystem.Drawing.Size(71,41);
this.minus.TabIndex=16;
this.minus.Text="-";
this.minus.UseVisualStyleBackColor=true;
this.minus.Click+=newSystem.EventHandler(this.minus_Click);
//
//multiplication
//
this.multiplication.Location=newSystem.Drawing.Point(305,312);
this.multiplication.Name="multiplication";
this.multiplication.Size=newSystem.Drawing.Size(71,41);
this.multiplication.TabIndex=17;
this.multiplication.Text="*";
this.multiplication.UseVisualStyleBackColor=true;
this.multiplication.Click+=newSystem.EventHandler(this.multiplication_Click);
//
//division
//
this.division.Location=newSystem.Drawing.Point(305,372);
this.division.Name="division";
this.division.Size=newSystem.Drawing.Size(71,41);
this.division.TabIndex=18;
this.division.Text="/";
this.division.UseVisualStyleBackColor=true;
this.division.Click+=newSystem.EventHandler(this.division_Click);
//
//plus
//
this.plus.Location=newSystem.Drawing.Point(305,199);
this.plus.Name="plus";
this.plus.Size=newSystem.Drawing.Size(71,41);
this.plus.TabIndex=19;
this.plus.Text="+";
this.plus.UseVisualStyleBackColor=true;
this.plus.Click+=newSystem.EventHandler(this.plus_Click);
//
//equal
//
this.equal.Location=newSystem.Drawing.Point(218,372);
this.equal.Name="equal";
this.equal.Size=newSystem.Drawing.Size(71,41);
this.equal.TabIndex=20;
this.equal.Text="=";
this.equal.UseVisualStyleBackColor=true;
this.equal.Click+=newSystem.EventHandler(this.equal_Click);
//
//Form1
//
this.AutoScaleDimensions=newSystem.Drawing.SizeF(8F,15F);
this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize=newSystem.Drawing.Size(502,466);
this.Controls.Add(this.equal);
this.Controls.Add(this.plus);
this.Controls.Add(this.division);
this.Controls.Add(this.multiplication);
this.Controls.Add(this.minus);
this.Controls.Add(this.clean);
this.Controls.Add(this.num0);
this.Controls.Add(this.num3);
this.Controls.Add(this.num2);
this.Controls.Add(this.num9);
this.Controls.Add(this.num4);
this.Controls.Add(this.num5
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年高考英語完型填空中常出現(xiàn)的650個高頻詞匯詞組
- DB36-T1697-2022-加工用南酸棗鮮果質(zhì)量等級-江西省
- 2025年北京市平谷區(qū)九年級初三二模物理試卷(含答案)
- 2025年小學(xué)二年級數(shù)學(xué)100以內(nèi)加減法混合運算能力測評與同步練習(xí)卷
- 排尿護(hù)理醫(yī)學(xué)體系構(gòu)建
- 2025年小學(xué)英語畢業(yè)模擬試卷:英語翻譯技巧深度解析試題
- 三年級數(shù)學(xué)計算題專項練習(xí)匯編及答案集錦
- 廣西興安縣三中2019-2020學(xué)年高二下學(xué)期開學(xué)測試題含解析(政治)
- 高中物理魯科版 (2019)必修 第一冊第3節(jié) 摩擦力當(dāng)堂檢測題
- 2025年醫(yī)保知識考試題庫及答案:醫(yī)?;颊邫?quán)益保障案例分析真題解析
- 施工單位平安工地考核評價表(標(biāo)準(zhǔn))
- 建筑材料分類整理
- 人民幣發(fā)展史-課件(PPT演示)
- 經(jīng)歷是流經(jīng)裙邊的水
- 工作票培訓(xùn)-課件
- 骨科疾病的康復(fù)課件
- 三氯乙醛 氯醛MSDS危險化學(xué)品安全技術(shù)說明書
- 合作社貸款申請書范文(優(yōu)選十三篇)
- 產(chǎn)品平臺與CBB技術(shù)管理課件
- 鑿井穩(wěn)車安裝安全技術(shù)交底-
- 學(xué)院學(xué)生紀(jì)律處分登記表
評論
0/150
提交評論