private void button_Clear_Click(object sender, EventArgs e) { Display_NumberInput.Text = Convert.ToString("0"); Display_Calc_Number.ResetText(); Disp_Calc_Symbol.ResetText(); }
private void button_Equal_Click(object sender, EventArgs e) { try { checked { int Input_data = 0; int Calc_data = 0; int Equal_data = 0; if (Disp_Calc_Symbol.Text != "") { if (Disp_Calc_Symbol.Text != "E") { if (Display_Calc_Number.Text != "") { Input_data = Convert.ToInt32(Display_Calc_Number.Text); } if (Display_NumberInput.Text != "") { Calc_data = Convert.ToInt32(Display_NumberInput.Text); switch (Disp_Calc_Symbol.Text) { case "+": Equal_data = Input_data + Calc_data; break; case "-": Equal_data = Input_data - Calc_data; break; case "×": Equal_data = Input_data * Calc_data; break; case "÷": if (Calc_data == 0) { Display_NumberInput.Text = "0で割るやつとかwww"; Disp_Calc_Symbol.Text = "E"; } else { Equal_data = (Input_data / Calc_data); } break; } Display_NumberInput.Text = Convert.ToString(Equal_data); } else { Display_NumberInput.Text = Display_Calc_Number.Text; } Display_Calc_Number.ResetText(); Disp_Calc_Symbol.ResetText(); } } else if (Disp_Calc_Symbol.Text == "E") { } } } catch (OverflowException ex) { Console.WriteLine("CHECKED and CAUGHT: " + ex.ToString()); Display_NumberInput.Text = "-------"; Display_Calc_Number.Text = ""; Disp_Calc_Symbol.Text = "E"; } }