private void nbutton(string stN) { if (M == null) { M = new clsMath(); //create a new instance if one does not exist DecUpdate(stN); //decimal handler } else if (txtDisplay.Text == "0") { DecUpdate(stN); //decimal handler } else { DecUpdate(stN); //decimal handler M.A = txtDisplay.Text + stN; //appends text to existing tect in textbox } if (M.A == "Error") { M.A = null; lblError.Text = "Must enter numbers only"; } else if (M.A == "more10") { lblError.Text = "Can only enter 10 numbers"; } else { txtDisplay.Text = M.A; //updateds textbox on from based on the class propriety lblError.Text = ""; } }
private void btnClear_Click(object sender, EventArgs e) //clears all data { M = null; lblN.Text = "Simple Calculator"; txtDisplay.Text = "0"; nbutton("0"); }
private void OpButton_Click(object sender, EventArgs e) //method for getting which operator was pressed { if (M != null) { Button buttonOP = (Button)sender; if (trackCelc) { trackCelc = false; M = null; nbutton(txtDisplay.Text); //method for updating text boxes and putting data into memory } M.B = M.A; //moves data to secondary holder lblN.Text = M.A.ToString() + " " + buttonOP.Text; //updates label on top of from M.A = null; txtDisplay.Text = "0"; M.Operation = buttonOP.Text; //Stores the operator in the class propriety } }