private void btnDiv_Click(object sender, EventArgs e) { mathJ calc = new mathJ(); try { Oper1 = Convert.ToDouble(Input); } catch (Exception except1) { Input = "0"; MessageBox.Show(except1.Message); } OP = "/"; //calc.Add(Input); // calc.Op = "/"; Input = string.Empty; }
private void btnEql_Click(object sender, EventArgs e) { mathJ calc = new mathJ(); try { Oper2 = Convert.ToDouble(Input); } catch (Exception except1) { Input = "0"; MessageBox.Show(except1.Message); } calc.Equals(Oper1, Oper2, OP); Input = Convert.ToString(calc.CurrentValue); if (OP == "/" && Oper2 == 0) { Input = null; txtShow.Text = "Error"; MessageBox.Show("Invalid division by 0 found"); } txtShow.Text = Input; WriteData(calc.CurrentValue); }
private void btnNegative_Click(object sender, EventArgs e) { Input = txtShow.Text; if (Input != "0") { mathJ calc = new mathJ(); try { Oper1 = Convert.ToDouble(Input); } catch (Exception except1) { Input = "0"; MessageBox.Show(except1.Message); } OP = "-"; calc.Substract(Input); //calc.Op = "+"; Input = string.Empty; txtShow.Text = Input; } if (Input == "0") { Input = "-"; txtShow.Text = Input; } }
public FrmCalculator() { InitializeComponent(); txtShow.Text = "0"; Input = null; mathJ calc = new mathJ(); calc.Op = Convert.ToString(txtShow.Text); }