110,571
社区成员
发帖
与我相关
我的任务
分享
private void NumButton_Click(object sender, EventArgs e)
{
if (bAppend)
{//在追加状态
Button btn = sender as Button;
if (btn.Text == "0")
{
if (textBoxResult.Text == "")
{
textBoxResult.Text += "0";
}
else if (textBoxResult.Text == "0")
{
textBoxResult.Text +=btn.Text ;
}
}
else
{
if (textBoxResult.Text == "0")
{
textBoxResult.Text = "";
}
textBoxResult.Text += btn.Text;
}
}
else
{
textBoxResult.Text = "";//清空
Button btn = sender as Button;
textBoxResult.Text += btn.Text;
bAppend = true;
}
}
if (btn.Text == "0")
{
if (textBoxResult.Text == "") //为空时仅显示一个0
{
textBoxResult.Text += "0";
}
else if (textBoxResult.Text == "0")
{
textBoxResult.Text +=btn.Text ;
}
else
{
textBoxResult.Text +=btn.Text ;
}
}