package 赤松電卓_通常版_; import System.Collections.Generic.*; import System.Data.*; import System.Drawing.*; import System.ComponentModel.*; import System.Windows.Forms.*; /** * Form1 の概要の説明です。 */ public class Form1 extends System.Windows.Forms.Form { private Label label2; private Button button1; private Button button2; private Button button3; private Button button4; private Button button5; private Button button6; private Button button7; private Button button8; private Button button9; private Button button10; private Button button11; private Button button12; private Button button13; private Button button14; private Button button15; private TextBox textBox1; private Button button16; private Label hantei; // 四則演算判定 private Label data; // 計算スタッグ /** * 必要なデザイナ変数です。 */ private System.ComponentModel.IContainer components; public Form1() { // // Windows フォーム デザイナのサポートに必要です // InitializeComponent(); // // TODO: InitializeComponent 呼び出しの後でコンストラクタ コードを追加します // } #region Windows フォーム デザイナで生成されたコード /** * 使用中のリソースをすべてクリーンアップします。 */ protected void Dispose(boolean disposing) { if (disposing) { if (components != null) { components.Dispose(); } } super.Dispose(disposing); } /** * デザイナ サポートに必要なメソッドです。このメソッドの内容を * コード エディタで変更しないでください。 */ private void InitializeComponent() { this.label2 = new System.Windows.Forms.Label(); 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.button11 = new System.Windows.Forms.Button(); this.button12 = new System.Windows.Forms.Button(); this.button13 = new System.Windows.Forms.Button(); this.button14 = new System.Windows.Forms.Button(); this.button15 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button16 = new System.Windows.Forms.Button(); this.hantei = new System.Windows.Forms.Label(); this.data = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label2 // this.label2.set_AutoSize(true); this.label2.set_Location(new System.Drawing.Point(160, 25)); this.label2.set_Name("label2"); this.label2.set_Size(new System.Drawing.Size(0, 12)); this.label2.set_TabIndex(1); // // button1 // this.button1.set_Location(new System.Drawing.Point(26, 124)); this.button1.set_Name("button1"); this.button1.set_Size(new System.Drawing.Size(30, 27)); this.button1.set_TabIndex(2); this.button1.set_Text("1"); this.button1.set_UseVisualStyleBackColor(true); this.button1.add_Click(new System.EventHandler(this.button1_Click)); // // button2 // this.button2.set_Location(new System.Drawing.Point(62, 124)); this.button2.set_Name("button2"); this.button2.set_Size(new System.Drawing.Size(30, 27)); this.button2.set_TabIndex(3); this.button2.set_Text("2"); this.button2.set_UseVisualStyleBackColor(true); this.button2.add_Click(new System.EventHandler(this.button2_Click)); // // button3 // this.button3.set_Location(new System.Drawing.Point(98, 124)); this.button3.set_Name("button3"); this.button3.set_Size(new System.Drawing.Size(30, 27)); this.button3.set_TabIndex(4); this.button3.set_Text("3"); this.button3.set_UseVisualStyleBackColor(true); this.button3.add_Click(new System.EventHandler(this.button3_Click)); // // button4 // this.button4.set_Location(new System.Drawing.Point(26, 91)); this.button4.set_Name("button4"); this.button4.set_Size(new System.Drawing.Size(30, 27)); this.button4.set_TabIndex(5); this.button4.set_Text("4"); this.button4.set_UseVisualStyleBackColor(true); this.button4.add_Click(new System.EventHandler(this.button4_Click)); // // button5 // this.button5.set_Location(new System.Drawing.Point(62, 91)); this.button5.set_Name("button5"); this.button5.set_Size(new System.Drawing.Size(30, 27)); this.button5.set_TabIndex(6); this.button5.set_Text("5"); this.button5.set_UseVisualStyleBackColor(true); this.button5.add_Click(new System.EventHandler(this.button5_Click)); // // button6 // this.button6.set_Location(new System.Drawing.Point(99, 91)); this.button6.set_Name("button6"); this.button6.set_Size(new System.Drawing.Size(29, 27)); this.button6.set_TabIndex(7); this.button6.set_Text("6"); this.button6.set_UseVisualStyleBackColor(true); this.button6.add_Click(new System.EventHandler(this.button6_Click)); // // button7 // this.button7.set_Location(new System.Drawing.Point(26, 58)); this.button7.set_Name("button7"); this.button7.set_Size(new System.Drawing.Size(30, 27)); this.button7.set_TabIndex(8); this.button7.set_Text("7"); this.button7.set_UseVisualStyleBackColor(true); this.button7.add_Click(new System.EventHandler(this.button7_Click)); // // button8 // this.button8.set_Location(new System.Drawing.Point(62, 58)); this.button8.set_Name("button8"); this.button8.set_Size(new System.Drawing.Size(30, 27)); this.button8.set_TabIndex(9); this.button8.set_Text("8"); this.button8.set_UseVisualStyleBackColor(true); this.button8.add_Click(new System.EventHandler(this.button8_Click)); // // button9 // this.button9.set_Location(new System.Drawing.Point(98, 58)); this.button9.set_Name("button9"); this.button9.set_Size(new System.Drawing.Size(29, 27)); this.button9.set_TabIndex(10); this.button9.set_Text("9"); this.button9.set_UseVisualStyleBackColor(true); this.button9.add_Click(new System.EventHandler(this.button9_Click)); // // button10 // this.button10.set_Location(new System.Drawing.Point(26, 157)); this.button10.set_Name("button10"); this.button10.set_Size(new System.Drawing.Size(30, 27)); this.button10.set_TabIndex(11); this.button10.set_Text("0"); this.button10.set_UseVisualStyleBackColor(true); this.button10.add_Click(new System.EventHandler(this.button10_Click)); // // button11 // this.button11.set_Location(new System.Drawing.Point(154, 157)); this.button11.set_Name("button11"); this.button11.set_Size(new System.Drawing.Size(30, 27)); this.button11.set_TabIndex(12); this.button11.set_Text("+"); this.button11.set_UseVisualStyleBackColor(true); this.button11.add_Click(new System.EventHandler(this.button11_Click)); // // button12 // this.button12.set_Location(new System.Drawing.Point(154, 124)); this.button12.set_Name("button12"); this.button12.set_Size(new System.Drawing.Size(30, 27)); this.button12.set_TabIndex(13); this.button12.set_Text("-"); this.button12.set_UseVisualStyleBackColor(true); this.button12.add_Click(new System.EventHandler(this.button12_Click)); // // button13 // this.button13.set_Location(new System.Drawing.Point(154, 91)); this.button13.set_Name("button13"); this.button13.set_Size(new System.Drawing.Size(30, 27)); this.button13.set_TabIndex(14); this.button13.set_Text("×"); this.button13.set_UseVisualStyleBackColor(true); this.button13.add_Click(new System.EventHandler(this.button13_Click)); // // button14 // this.button14.set_Location(new System.Drawing.Point(154, 58)); this.button14.set_Name("button14"); this.button14.set_Size(new System.Drawing.Size(30, 27)); this.button14.set_TabIndex(15); this.button14.set_Text("÷"); this.button14.set_UseVisualStyleBackColor(true); this.button14.add_Click(new System.EventHandler(this.button14_Click)); // // button15 // this.button15.set_Location(new System.Drawing.Point(201, 158)); this.button15.set_Name("button15"); this.button15.set_Size(new System.Drawing.Size(30, 26)); this.button15.set_TabIndex(16); this.button15.set_Text("="); this.button15.set_UseVisualStyleBackColor(true); this.button15.add_Click(new System.EventHandler(this.button15_Click)); // // textBox1 // this.textBox1.set_Location(new System.Drawing.Point(26, 22)); this.textBox1.set_Name("textBox1"); this.textBox1.set_ReadOnly(true); this.textBox1.set_RightToLeft(System.Windows.Forms.RightToLeft.Yes); this.textBox1.set_Size(new System.Drawing.Size(128, 19)); this.textBox1.set_TabIndex(17); this.textBox1.set_Text("0"); // // button16 // this.button16.set_Location(new System.Drawing.Point(201, 58)); this.button16.set_Name("button16"); this.button16.set_Size(new System.Drawing.Size(30, 27)); this.button16.set_TabIndex(18); this.button16.set_Text("C"); this.button16.set_UseVisualStyleBackColor(true); this.button16.add_Click(new System.EventHandler(this.button16_Click)); // // hantei // this.hantei.set_Location(new System.Drawing.Point(26, 191)); this.hantei.set_Name("hantei"); this.hantei.set_Size(new System.Drawing.Size(0, 0)); this.hantei.set_TabIndex(19); this.hantei.set_Text("0"); // // data // this.data.set_Location(new System.Drawing.Point(57, 191)); this.data.set_Name("data"); this.data.set_Size(new System.Drawing.Size(0, 0)); this.data.set_TabIndex(20); this.data.set_Text("0"); // // Form1 // this.set_AutoScaleDimensions(new System.Drawing.SizeF(6F, 12F)); this.set_AutoScaleMode(System.Windows.Forms.AutoScaleMode.Font); this.set_ClientSize(new System.Drawing.Size(260, 204)); this.get_Controls().Add(this.data); this.get_Controls().Add(this.hantei); this.get_Controls().Add(this.button16); this.get_Controls().Add(this.textBox1); this.get_Controls().Add(this.button15); this.get_Controls().Add(this.button14); this.get_Controls().Add(this.button13); this.get_Controls().Add(this.button12); this.get_Controls().Add(this.button11); this.get_Controls().Add(this.button10); this.get_Controls().Add(this.button9); this.get_Controls().Add(this.button8); this.get_Controls().Add(this.button7); this.get_Controls().Add(this.button6); this.get_Controls().Add(this.button5); this.get_Controls().Add(this.button4); this.get_Controls().Add(this.button3); this.get_Controls().Add(this.button2); this.get_Controls().Add(this.button1); this.get_Controls().Add(this.label2); this.set_Name("Form1"); this.set_Text("赤松電卓ver1.01"); this.ResumeLayout(false); this.PerformLayout(); } #endregion // 下記 0〜9 までのボタンの動作 private void button1_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 1; this.textBox1.set_Text("" + z); } private void button2_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 2; this.textBox1.set_Text("" + z); } private void button3_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 3; this.textBox1.set_Text("" + z); } private void button4_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 4; this.textBox1.set_Text("" + z); } private void button5_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 5; this.textBox1.set_Text("" + z); } private void button6_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 6; this.textBox1.set_Text("" + z); } private void button7_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 7; this.textBox1.set_Text("" + z); } private void button8_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 8; this.textBox1.set_Text("" + z); } private void button9_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 9; this.textBox1.set_Text("" + z); } private void button10_Click(Object sender, System.EventArgs e) { int x = Integer.parseInt(textBox1.get_Text()); int y = x * 10; int z = y + 0; this.textBox1.set_Text("" + z); } // 上記 0〜9 までのボタンの動作 // ここから+−×÷のキーの動作 // 1 2 3 4(判定番号) private void button15_Click(Object sender, System.EventArgs e) { int hanteirecord = Integer.parseInt(hantei.get_Text()); int Datarecord = Integer.parseInt(data.get_Text()); int y = Integer.parseInt(textBox1.get_Text()); if (hanteirecord == 1) { int x = Datarecord + y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 2) { int x = Datarecord - y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 3) { int x = Datarecord * y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 4) { int x = Datarecord / y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 0) { } else { this.textBox1.set_Text("エラー発生"); hanteirecord = 0; } this.data.set_Text("" + 0); this.hantei.set_Text("" + 0); this.label2.set_Text(""); } private void button11_Click(Object sender, System.EventArgs e) { int hanteirecord = Integer.parseInt(hantei.get_Text()); int Datarecord = Integer.parseInt(data.get_Text()); int y = Integer.parseInt(textBox1.get_Text()); if (hanteirecord == 1) { int x = Datarecord + y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 2) { int x = Datarecord - y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 3) { int x = Datarecord * y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 4) { int x = Datarecord / y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 0) { } else { this.textBox1.set_Text("エラー発生"); hanteirecord = 0; } hanteirecord = 1; this.hantei.set_Text("" + hanteirecord); int datarecord = Integer.parseInt(textBox1.get_Text()); this.data.set_Text("" + datarecord); this.textBox1.set_Text("" + 0); this.label2.set_Text("足し算"); } private void button13_Click(Object sender, System.EventArgs e) { int hanteirecord = Integer.parseInt(hantei.get_Text()); int Datarecord = Integer.parseInt(data.get_Text()); int y = Integer.parseInt(textBox1.get_Text()); if (hanteirecord == 1) { int x = Datarecord + y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 2) { int x = Datarecord - y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 3) { int x = Datarecord * y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 4) { int x = Datarecord / y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 0) { } else { this.textBox1.set_Text("エラー発生"); hanteirecord = 0; } hanteirecord = 3; this.hantei.set_Text("" + hanteirecord); int datarecord = Integer.parseInt(textBox1.get_Text()); this.data.set_Text("" + datarecord); this.textBox1.set_Text("" + 0); this.label2.set_Text("掛け算"); } private void button14_Click(Object sender, System.EventArgs e) { int hanteirecord = Integer.parseInt(hantei.get_Text()); int Datarecord = Integer.parseInt(data.get_Text()); int y = Integer.parseInt(textBox1.get_Text()); if (hanteirecord == 1) { int x = Datarecord + y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 2) { int x = Datarecord - y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 3) { int x = Datarecord * y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 4) { int x = Datarecord / y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 0) { } else { this.textBox1.set_Text("エラー発生"); hanteirecord = 0; } hanteirecord = 4; this.hantei.set_Text("" + hanteirecord); int datarecord = Integer.parseInt(textBox1.get_Text()); this.data.set_Text("" + datarecord); this.textBox1.set_Text("" + 0); this.label2.set_Text("割り算"); } private void button12_Click(Object sender, System.EventArgs e) { int hanteirecord = Integer.parseInt(hantei.get_Text()); int Datarecord = Integer.parseInt(data.get_Text()); int y = Integer.parseInt(textBox1.get_Text()); this.label2.set_Text(""); if (hanteirecord == 1) { int x = Datarecord + y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 2) { int x = Datarecord - y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 3) { int x = Datarecord * y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 4) { int x = Datarecord / y; this.textBox1.set_Text("" + x); hanteirecord = 0; } else if (hanteirecord == 0) { } else { this.textBox1.set_Text("エラー発生"); hanteirecord = 0; } hanteirecord = 2; this.hantei.set_Text("" + hanteirecord); int datarecord = Integer.parseInt(textBox1.get_Text()); this.data.set_Text("" + datarecord); this.textBox1.set_Text("" + 0); this.label2.set_Text("引き算"); } //下記クリアボタンの動作 private void button16_Click(Object sender, System.EventArgs e) { this.textBox1.set_Text("" + 0); this.data.set_Text("" + 0); this.hantei.set_Text("" + 0); this.label2.set_Text(""); } }