Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication23
{
public partial class Form1 : Form
{
int sign_Indicator = 0;
double variable1;
double variable2;
int additionPart = 0;
int subbtractionPart = 0;
int multiplicationPart = 0;
int divisionPart = 0;
int modBit = 0;
Boolean fl = false;
String s, x;
public Form1()
{
InitializeComponent();
}
float num1, ans;
int count;
private void button17_Click(object sender, EventArgs e)
{
textBox1.Clear();
count = 0;
}
private void button9_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text = textBox1.Text + Convert.ToString(1);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(1);
sign_Indicator = 0;
}
fl = true;
}
private void button10_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(2);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(2);
sign_Indicator = 0;
}
fl = true;
}
private void button11_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(3);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(3);
sign_Indicator = 0;
}
fl = true;
}
private void button5_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(4);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(4);
sign_Indicator = 0;
}
fl = true;
}
private void button6_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(5);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(5);
sign_Indicator = 0;
}
fl = true;
}
private void button7_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(6);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(6);
sign_Indicator = 0;
}
fl = true;
}
private void button1_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(7);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(7);
sign_Indicator = 0;
}
fl = true;
}
private void button2_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(8);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(8);
sign_Indicator = 0;
}
fl = true;
}
private void button3_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(9);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(9);
sign_Indicator = 0;
}
fl = true;
}
private void button13_Click(object sender, EventArgs e)
{
if (sign_Indicator == 0)
{
textBox1.Text =textBox1.Text + Convert.ToString(0);
}
else if (sign_Indicator == 1)
{
textBox1.Text = Convert.ToString(0);
sign_Indicator = 0;
}
fl = true;
}
private void button15_Click(object sender, EventArgs e)
{
compute(count);
}
public void compute(int count)
{
switch (count)
{
case 1:
ans = num1 - float.Parse(textBox1.Text);
textBox1.Text = ans.ToString();
break;
case 2:
ans = num1 + float.Parse(textBox1.Text);
textBox1.Text = ans.ToString();
break;
case 3:
ans = num1 * float.Parse(textBox1.Text);
textBox1.Text = ans.ToString();
break;
case 4:
ans = num1 / float.Parse(textBox1.Text);
textBox1.Text = ans.ToString();
break;
case 5:
ans = num1 % float.Parse(textBox1.Text);
textBox1.Text = ans.ToString();
break;
default:
break;
}
}
private void button16_Click(object sender, EventArgs e)
{
num1 = float.Parse(textBox1.Text);
textBox1.Clear();
textBox1.Focus();
count = 2;
}
private void button12_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
num1 = float.Parse(textBox1.Text);
textBox1.Clear();
textBox1.Focus();
count = 1;
}
}
private void button8_Click(object sender, EventArgs e)
{
num1 = float.Parse(textBox1.Text);
textBox1.Clear();
textBox1.Focus();
count = 3;
}
private void button4_Click(object sender, EventArgs e)
{
num1 = float.Parse(textBox1.Text);
textBox1.Clear();
textBox1.Focus();
count = 4;
}
private void button14_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + '.';
}
private void button18_Click(object sender, EventArgs e)
{
MessageBox.Show("OK to exit");
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button20_Click(object sender, EventArgs e)
{
double s, l;
l = Convert.ToDouble(textBox1.Text);
s = Math.Sqrt(l);
textBox1.Text = Convert.ToString(s);
}
private void button21_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Length != 0)
{
double l;
l = Math.Log(Convert.ToDouble(textBox1.Text));
textBox1.Text = Convert.ToString(l);
}
sign_Indicator = 1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button22_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Length != 0)
{
double l;
l = Math.Log10(Convert.ToDouble(textBox1.Text));
textBox1.Text = Convert.ToString(l);
}
sign_Indicator = 1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button23_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Length != 0)
{
double l;
l = Math.Exp(Convert.ToDouble(textBox1.Text));
textBox1.Text = Convert.ToString(l);
}
sign_Indicator = 1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button19_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Length != 0)
{
double l;
l = Math.Sin(Convert.ToDouble(textBox1.Text));
textBox1.Text = Convert.ToString(l);
}
sign_Indicator = 1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button24_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Length != 0)
{
double l;
l = Math.Cos(Convert.ToDouble(textBox1.Text));
textBox1.Text = Convert.ToString(l);
}
sign_Indicator = 1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button25_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Length != 0)
{
double l;
l = Math.Tan(Convert.ToDouble(textBox1.Text));
textBox1.Text = Convert.ToString(l);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button26_Click(object sender, EventArgs e)
{
num1 = float.Parse(textBox1.Text);
textBox1.Clear();
textBox1.Focus();
count = 5;
}
}
No comments:
Post a Comment