Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Form1.cs
- private void AddButton_Click(object sender, EventArgs e) {
- if (FirstNumber.Text == "" && SecondNumber.Text == "") {
- Answer.Text = "";
- return;
- }
- this.Answer.Text = ((Int32.Parse(FirstNumber.Text)) + (Int32.Parse(SecondNumber.Text))).ToString();
- }
- // Form1.Designer.cs
- namespace WindowsFormsApplication1 {
- partial class Form1 {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing) {
- if (disposing && (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.AddButton = new System.Windows.Forms.Button();
- this.FirstNumber = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.SecondNumber = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.Answer = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // AddButton
- //
- this.AddButton.Location = new System.Drawing.Point(128, 76);
- this.AddButton.Name = "AddButton";
- this.AddButton.Size = new System.Drawing.Size(100, 29);
- this.AddButton.TabIndex = 0;
- this.AddButton.Text = "Add";
- this.AddButton.UseVisualStyleBackColor = true;
- this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
- //
- // FirstNumber
- //
- this.FirstNumber.AccessibleRole = System.Windows.Forms.AccessibleRole.Text;
- this.FirstNumber.Location = new System.Drawing.Point(128, 22);
- this.FirstNumber.Name = "FirstNumber";
- this.FirstNumber.Size = new System.Drawing.Size(100, 20);
- this.FirstNumber.TabIndex = 1;
- this.FirstNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(41, 25);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(69, 13);
- this.label1.TabIndex = 2;
- this.label1.Text = "First Number:";
- //
- // SecondNumber
- //
- this.SecondNumber.Location = new System.Drawing.Point(128, 48);
- this.SecondNumber.Name = "SecondNumber";
- this.SecondNumber.Size = new System.Drawing.Size(100, 20);
- this.SecondNumber.TabIndex = 8;
- this.SecondNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(41, 51);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(87, 13);
- this.label3.TabIndex = 9;
- this.label3.Text = "Second Number:";
- this.label3.Click += new System.EventHandler(this.label3_Click);
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(41, 111);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(45, 13);
- this.label4.TabIndex = 10;
- this.label4.Text = "Answer:";
- //
- // Answer
- //
- this.Answer.AccessibleRole = System.Windows.Forms.AccessibleRole.Text;
- this.Answer.Location = new System.Drawing.Point(128, 111);
- this.Answer.Name = "Answer";
- this.Answer.ReadOnly = true;
- this.Answer.Size = new System.Drawing.Size(100, 20);
- this.Answer.TabIndex = 11;
- this.Answer.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(269, 146);
- this.Controls.Add(this.Answer);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.SecondNumber);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.FirstNumber);
- this.Controls.Add(this.AddButton);
- this.Name = "Form1";
- this.Text = "Simple Calculator";
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private System.Windows.Forms.Button AddButton;
- private System.Windows.Forms.TextBox FirstNumber;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox SecondNumber;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.TextBox Answer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement