Tuesday, November 18, 2008

Simple Calculator In Windows Application Using C#

0 comments 11/18/2008
Sign up to receive our site updates!
Design Form As





namespace calc

{

public partial class Form1 : Form

{

int temp, fn, sn, tot, op;

double fn1, temp1, sn1, tot1;

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

}

private void button16_Click_1(object sender, EventArgs e)

{

textBox1.Text = "";

textBox1.Focus();

}



private void button17_Click_1(object sender, EventArgs e)

{

MessageBox.Show("Thanks for using this CAlculator", "Thanks");

Application.Exit();

}

private void button15_Click_1(object sender, EventArgs e)

{

switch (op)

{

case 1:

sn = int.Parse(textBox1.Text);

tot = temp + sn;

textBox1.Text = "";

textBox1.Text = tot.ToString();

break;

case 2:

sn = int.Parse(textBox1.Text);

tot = temp - sn;

textBox1.Text = "";

textBox1.Text = tot.ToString();

break;

case 3:

sn = int.Parse(textBox1.Text);

tot = temp * sn;

textBox1.Text = "";

textBox1.Text = tot.ToString();

break;



case 4:

sn1 = double.Parse(textBox1.Text);

tot1 = temp1 / sn1;

textBox1.Text = "";

textBox1.Text = tot1.ToString();

break;

}

}



private void button14_Click_1(object sender, EventArgs e)

{

fn1 = Convert.ToDouble(double.Parse(textBox1.Text));

temp1 = fn1;

textBox1.Text = "";

op = 4;

}



private void button13_Click_1(object sender, EventArgs e)

{

fn = Convert.ToInt32(int.Parse(textBox1.Text));

temp = fn;

textBox1.Text = "";

op = 3;

}



private void button12_Click_1(object sender, EventArgs e)

{

fn = int.Parse(textBox1.Text);

temp = fn;

textBox1.Text = "";

op = 2;

}



private void button11_Click_1(object sender, EventArgs e)

{

fn = int.Parse(textBox1.Text);

temp = fn;

textBox1.Text = "";

op = 1;

}



private void button1_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "1";

}



private void button2_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "2";

}



private void button3_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "3";

}



private void button4_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "4";

}



private void button5_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "5";

}



private void button6_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "6";

}



private void button7_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "7";

}



private void button8_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "8";

}



private void button9_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "9";

}



private void button10_Click_1(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + "0";

}

}

}



Your Ad Here

0 comments:

Respects for your's Questions & Opinions

  • Friends
  •  

    Recent Posts

    Copyright 2008 All Rights Reserved Tech Tasks Template by Rajesh Kumar Chekuri