Take 3 text Boxes, 8 Buttons on Form 1 and Set button layout according to you
Now Copy This Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace My_calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Double i;
private void button1_Click(object sender, EventArgs e)//double click on add Button
{
i = Convert.ToDouble(textBox1.Text);
Double j = Convert.ToDouble(textBox2.Text);
Double k = i + j;
textBox3.Text = k.ToString();
}
private void button2_Click(object sender, EventArgs e)//double click on minus Button
{
i = Convert.ToDouble(textBox1.Text);
Double j = Convert.ToDouble(textBox2.Text);
Double k = i - j;
textBox3.Text = k.ToString();
}
private void button3_Click(object sender, EventArgs e)//double click on multiply Button
{
i = Convert.ToDouble(textBox1.Text);
Double j = Convert.ToDouble(textBox2.Text);
Double k = i * j;
textBox3.Text = k.ToString();
}
private void button4_Click(object sender, EventArgs e)//double click on divide Button
{
i = Convert.ToDouble(textBox1.Text);
Double j = Convert.ToDouble(textBox2.Text);
Double k = i / j;
textBox3.Text = k.ToString();
}
private void button5_Click(object sender, EventArgs e)//double click on square root Button
{
i = Convert.ToDouble(textBox1.Text);
//Double j = Convert.ToDouble(textBox2.Text);
Double k = i * i;
textBox3.Text = k.ToString();
}
private void button6_Click(object sender, EventArgs e)//double click on square cube Button
{
i = Convert.ToDouble(textBox1.Text);
//Double j = Convert.ToDouble(textBox2.Text);
Double k = i * i * i;
textBox3.Text = k.ToString();
}
private void button7_Click(object sender, EventArgs e)//double click on B(Blank) Button for clear text-boxes
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
private void button8_Click(object sender, EventArgs e)//double click on E(Exit) Button for closing application
{
Application.Exit();
}
}
}
now click F5 for run.............
Your Suggestion in Comment Box



I prefer merely excellent resources - you will see these people in: ounces in a pound
ReplyDelete