c#簡易計算器的制作.docx_第1頁
c#簡易計算器的制作.docx_第2頁
c#簡易計算器的制作.docx_第3頁
c#簡易計算器的制作.docx_第4頁
c#簡易計算器的制作.docx_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

namespace 計算器試驗1 partial class Form1 / / 必需的設計器變量。 / private System.ComponentModel.IContainer components = null; / / 清理所有正在使用的資源。 / / 如果應釋放托管資源,為 true;否則為 false。 protected override void Dispose(bool disposing) if (disposing & (components != null) components.Dispose(); base.Dispose(disposing); #region Windows 窗體設計器生成的代碼 / / 設計器支持所需的方法 - 不要 / 使用代碼編輯器修改此方法的內容。 / private void InitializeComponent() this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.button7 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); this.button9 = new System.Windows.Forms.Button(); this.button10 = new System.Windows.Forms.Button(); this.buttonPt = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); this.buttonSub = new System.Windows.Forms.Button(); this.buttonMul = new System.Windows.Forms.Button(); this.buttonDiv = new System.Windows.Forms.Button(); this.buttonClear = new System.Windows.Forms.Button(); this.buttonResult = new System.Windows.Forms.Button(); this.SuspendLayout(); / / textBox1 / this.textBox1.Location = new System.Drawing.Point(12, 26); this.textBox1.Name = textBox1; this.textBox1.ReadOnly = true; this.textBox1.Size = new System.Drawing.Size(208, 21); this.textBox1.TabIndex = 17; / / button1 / this.button1.Location = new System.Drawing.Point(12, 170); this.button1.Name = button1; this.button1.Size = new System.Drawing.Size(46, 32); this.button1.TabIndex = 18; this.button1.Text = 1; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); / / button2 / this.button2.Location = new System.Drawing.Point(74, 170); this.button2.Name = button2; this.button2.Size = new System.Drawing.Size(46, 32); this.button2.TabIndex = 19; this.button2.Text = 2; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); / / button3 / this.button3.Location = new System.Drawing.Point(136, 170); this.button3.Name = button3; this.button3.Size = new System.Drawing.Size(46, 32); this.button3.TabIndex = 20; this.button3.Text = 3; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); / / button4 / this.button4.Location = new System.Drawing.Point(12, 120); this.button4.Name = button4; this.button4.Size = new System.Drawing.Size(46, 32); this.button4.TabIndex = 21; this.button4.Text = 4; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); / / button5 / this.button5.Location = new System.Drawing.Point(74, 120); this.button5.Name = button5; this.button5.Size = new System.Drawing.Size(46, 32); this.button5.TabIndex = 22; this.button5.Text = 5; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); / / button6 / this.button6.Location = new System.Drawing.Point(136, 120); this.button6.Name = button6; this.button6.Size = new System.Drawing.Size(46, 32); this.button6.TabIndex = 23; this.button6.Text = 6; this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_Click); / / button7 / this.button7.Location = new System.Drawing.Point(12, 71); this.button7.Name = button7; this.button7.Size = new System.Drawing.Size(46, 32); this.button7.TabIndex = 24; this.button7.Text = 7; this.button7.UseVisualStyleBackColor = true; this.button7.Click += new System.EventHandler(this.button7_Click); / / button8 / this.button8.Location = new System.Drawing.Point(74, 71); this.button8.Name = button8; this.button8.Size = new System.Drawing.Size(46, 32); this.button8.TabIndex = 25; this.button8.Text = 8; this.button8.UseVisualStyleBackColor = true; this.button8.Click += new System.EventHandler(this.button8_Click); / / button9 / this.button9.Location = new System.Drawing.Point(136, 71); this.button9.Name = button9; this.button9.Size = new System.Drawing.Size(46, 32); this.button9.TabIndex = 26; this.button9.Text = 9; this.button9.UseVisualStyleBackColor = true; this.button9.Click += new System.EventHandler(this.button9_Click); / / button10 / this.button10.Location = new System.Drawing.Point(74, 218); this.button10.Name = button10; this.button10.Size = new System.Drawing.Size(46, 32); this.button10.TabIndex = 27; this.button10.Text = 0; this.button10.UseVisualStyleBackColor = true; this.button10.Click += new System.EventHandler(this.button10_Click); / / buttonPt / this.buttonPt.Location = new System.Drawing.Point(12, 218); this.buttonPt.Name = buttonPt; this.buttonPt.Size = new System.Drawing.Size(46, 32); this.buttonPt.TabIndex = 28; this.buttonPt.Text = .; this.buttonPt.UseVisualStyleBackColor = true; this.buttonPt.Click += new System.EventHandler(this.buttonPt_Click); / / buttonAdd / this.buttonAdd.Location = new System.Drawing.Point(212, 71); this.buttonAdd.Name = buttonAdd; this.buttonAdd.Size = new System.Drawing.Size(60, 32); this.buttonAdd.TabIndex = 29; this.buttonAdd.Text = +; this.buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); / / buttonSub / this.buttonSub.Location = new System.Drawing.Point(212, 120); this.buttonSub.Name = buttonSub; this.buttonSub.Size = new System.Drawing.Size(60, 32); this.buttonSub.TabIndex = 30; this.buttonSub.Text = -; this.buttonSub.UseVisualStyleBackColor = true; this.buttonSub.Click += new System.EventHandler(this.buttonSub_Click); / / buttonMul / this.buttonMul.Location = new System.Drawing.Point(212, 170); this.buttonMul.Name = buttonMul; this.buttonMul.Size = new System.Drawing.Size(60, 32); this.buttonMul.TabIndex = 31; this.buttonMul.Text = *; this.buttonMul.UseVisualStyleBackColor = true; this.buttonMul.Click += new System.EventHandler(this.buttonMul_Click); / / buttonDiv / this.buttonDiv.Location = new System.Drawing.Point(212, 218); this.buttonDiv.Name = buttonDiv; this.buttonDiv.Size = new System.Drawing.Size(60, 32); this.buttonDiv.TabIndex = 32; this.buttonDiv.Text = /; this.buttonDiv.UseVisualStyleBackColor = true; this.buttonDiv.Click += new System.EventHandler(this.buttonDiv_Click); / / buttonClear / this.buttonClear.Location = new System.Drawing.Point(226, 19); this.buttonClear.Name = buttonClear; this.buttonClear.Size = new System.Drawing.Size(46, 32); this.buttonClear.TabIndex = 33; this.buttonClear.Text = 清空; this.buttonClear.UseVisualStyleBackColor = true; this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click); / / buttonResult / this.buttonResult.Location = new System.Drawing.Point(136, 218); this.buttonResult.Name = buttonResult; this.buttonResult.Size = new System.Drawing.Size(46, 32); this.buttonResult.TabIndex = 34; this.buttonResult.Text = =; this.buttonResult.UseVisualStyleBackColor = true; this.buttonResult.Click += new System.EventHandler(this.buttonResult_Click); / / Form1 / this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 262); this.Controls.Add(this.buttonResult); this.Controls.Add(this.buttonClear); this.Controls.Add(this.buttonDiv); this.Controls.Add(this.buttonMul); this.Controls.Add(this.buttonSub); this.Controls.Add(this.buttonAdd); this.Controls.Add(this.buttonPt); this.Controls.Add(this.button10); this.Controls.Add(this.button9); this.Controls.Add(this.button8); this.Controls.Add(this.button7); this.Controls.Add(this.button6); this.Controls.Add(this.button5); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = Form1; this.Text = Form1; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); this.PerformLayout(); #endregion private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button6; private System.Windows.Forms.Button button7; private System.Windows.Forms.Button button8; private System.Windows.Forms.Button button9; private System.Windows.Forms.Button button10; private System.Windows.Forms.Button buttonPt; private System.Windows.Forms.Button buttonAdd; private System.Windows.Forms.Button buttonSub; private System.Windows.Forms.Button buttonMul; private System.Windows.Forms.Button buttonDiv; private System.Windows.Forms.Button buttonClear; private System.Windows.Forms.Button buttonResult; mespace 計算器試驗1 static class Program / / 應用程序的主入口點。 / STAThread static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1(); 下面是自己編的計算器程序public partial class Form1 : Form public Form1() InitializeComponent(); double doStep1, doStep2, result; string myAction; bool isPoint = false; private void Form1_Load(object sender, EventArgs e) textBox1.TextAlign = HorizontalAlignment.Right;/ 指定文本框的對齊方式為右對齊 private void button7_Click(object sender, EventArgs e) textBox1.Text += 7; private void button8_Click(object sender, EventArgs e) textBox1.Text += 8; private void button9_Click(object sender, EventArgs e) textBox1.Text += 9; private void button4_Click(object sender, EventArgs e) textBox1.Text += 4; private void button5_Click(object sender, EventArgs e) textBox1.Text += 5; private void button6_Click(object sender, EventArgs e) textBox1.Text += 6; private void button1_Click(object sender, EventArgs e) textBox1.Text += 1; private void button2_Click(object sender, EventArgs e) textBox1.Text += 2; private void button3_Click(object sender, EventArgs e) textBox1.Text += 3; private void button10_Click(object sender, EventArgs e) if (textBox1.Text.Length != 0) textBox1.Text += 0; private void buttonPt_Click(object sender, EventArgs e) if (!isPoint) textBox1.Text += .; private void buttonAdd_Click(object sender, EventArgs e) if (textBox1.Text.Length != 0) doStep1 = double.Parse(textBox1.Text); else doStep1

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論