对于之前的计算器有些地方稍加修改了,对于界面也美化了一下。
改背景图片和按钮的背景色在属性里改。
代码如下:乘法的代码
private void button15_Click(object sender, EventArgs e)
{
if (c == true)
{
textBox1.Text = "";
c = false;
}
d = "*";
a = int.Parse(s);
m*= a;
total= m;
textBox1.Text += "*";
s = "";
}
{
if (c == true)
{
textBox1.Text = "";
c = false;
}
d = "*";
a = int.Parse(s);
m*= a;
total= m;
textBox1.Text += "*";
s = "";
}
case里除法的代码:(之前是整除)
case "/":
b = int.Parse(s);
total /= b*1.0;
textBox1.Text += "=";
textBox1.Text += total.ToString();
break;
b = int.Parse(s);
total /= b*1.0;
textBox1.Text += "=";
textBox1.Text += total.ToString();
break;
改窗体名字的代码:
private void Frm_Main_Load(object sender, EventArgs e)
{
this.Text = "计算器美化初级版--yyy";
}
{
this.Text = "计算器美化初级版--yyy";
}
total变量由int改成了double。
其他部分和之前的一样。