Onlc

From Wikireedia
Jump to: navigation, search

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;

namespace Chapter1 { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;

public Form1() { // // Required for Windows Form Designer support // InitializeComponent();

// // TODO: Add any constructor code after InitializeComponent call // }

/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }

#region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.label1 = 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.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(40, 24); this.textBox1.Name = "textBox1"; this.textBox1.TabIndex = 0; this.textBox1.Text = ""; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(40, 72); this.textBox2.Name = "textBox2"; this.textBox2.TabIndex = 1; this.textBox2.Text = ""; // // label1 // this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.label1.Location = new System.Drawing.Point(40, 112); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(192, 23); this.label1.TabIndex = 2; this.label1.Text = "Answer will appear here"; this.label1.Click += new System.EventHandler(this.label1_Click); // // button1 // this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.button1.Location = new System.Drawing.Point(40, 160); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(168, 23); this.button1.TabIndex = 3; this.button1.Text = "+"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.button2.Location = new System.Drawing.Point(240, 160); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(168, 23); this.button2.TabIndex = 4; this.button2.Text = "-"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.button3.Location = new System.Drawing.Point(240, 216); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(168, 23); this.button3.TabIndex = 5; this.button3.Text = "/"; this.button3.Click += new System.EventHandler(this.button3_Click); // // button4 // this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.button4.Location = new System.Drawing.Point(40, 216); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(168, 23); this.button4.TabIndex = 6; this.button4.Text = "*"; this.button4.Click += new System.EventHandler(this.button4_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.SystemColors.Desktop; this.ClientSize = new System.Drawing.Size(568, 273); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.label1); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Name = "Form1"; this.Text = "Paul\'s Calculator"; this.ResumeLayout(false);

} #endregion

/// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); }

private void button1_Click(object sender, System.EventArgs e) { //this code add two numbers int num1;//=Convert.ToInt16(textBox1.text); int num2;//=Convert.ToInt16(textBox2.text); num1=Convert.ToInt16(this.textBox1.Text); num2=Convert.ToInt16(this.textBox2.Text);


label1.Text=Convert.ToString(num1 + num2);



}

private void button2_Click(object sender, System.EventArgs e) {

//this code add two numbers int num1;//=Convert.ToInt16(textBox1.text); int num2;//=Convert.ToInt16(textBox2.text); num1=Convert.ToInt16(this.textBox1.Text); num2=Convert.ToInt16(this.textBox2.Text);


label1.Text=Convert.ToString(num1 - num2); }

private void button4_Click(object sender, System.EventArgs e)

{ //this code add two numbers int num1;//=Convert.ToInt16(textBox1.text); int num2;//=Convert.ToInt16(textBox2.text); num1=Convert.ToInt16(this.textBox1.Text); num2=Convert.ToInt16(this.textBox2.Text);


label1.Text=Convert.ToString(num1 * num2);

}

private void button3_Click(object sender, System.EventArgs e) {

//this code add two numbers int num1;//=Convert.ToInt16(textBox1.text); int num2;//=Convert.ToInt16(textBox2.text); num1=Convert.ToInt16(this.textBox1.Text); num2=Convert.ToInt16(this.textBox2.Text);


label1.Text=Convert.ToString(num1 / num2);


}

private void label1_Click(object sender, System.EventArgs e) {

} } }

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox