【www.gdgbn.com--计数转换】
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;
}
}
}
}