private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置使用者代碼以初始化頁面
if(!this.IsPostBack)
{
// 數位顯示和存放
this.show.Text="0";
// 存放符號,如+
this.tp.Text="";
}
}
private void yi_Click(object sender, System.EventArgs e)
{
int tmp=Convert.ToInt32(this.show.Text);
// 沒有符號存在的情況下
if(this.tp.Text=="")
{
if(tmp==0)
{
this.show.Text="1";
}
else
{
this.show.Text+="1";
}
}
// 有符號存在的條件下
else
{
if(this.show.Text=="0")
{
this.show.Text="1";
}
else
{
this.show.Text+="1";
}
}
}
private void er_Click(object sender, System.EventArgs e)
{
int tmp=Convert.ToInt32(this.show.Text);
// 沒有符號存在的情況下
if(this.tp.Text=="")
{
if(tmp==0)
{
this.show.Text="2";
}
else
{
this.show.Text+="2";
}
}
// 有符號存在的條件下
else
{
if(this.show.Text=="0")
{
this.show.Text="2";
}
else
{
this.show.Text+="2";
}
}
}
private void jia_Click(object sender, System.EventArgs e)
{
if(this.tp.Text=="")
{
this.first.Text=this.show.Text;
this.tp.Text="+";
this.show.Text="0";
}
else
{
this.show.Text=Convert.ToString(Convert.ToInt32(this.first.Text)+Convert.ToInt32(this.show.Text));
this.tp.Text="+";
this.first.Text=this.show.Text;
this.show.Text="0";
}
}
private void deng_Click(object sender, System.EventArgs e)
{
if(this.tp.Text=="")
{
;
}
else
{
this.show.Text=Convert.ToString(Convert.ToInt32(this.first.Text)+Convert.ToInt32(this.show.Text));
this.tp.Text="";
this.first.Text=this.show.Text;
}
}
}
}