C# code关键部分代码:
public partial class frmStandCalculator : Form
{
public float number1 = 0;//存储前一个操作数;
public bool flag = false;//标记单击了操作符没有,false为还未击操作符,ture为单击了操作符
public char doflag = '+';//初始化操作符,单击了操作符时存储操作符号
public bool pointflag = false;//标志是否单击了小数点;false为未击,true为已经单击;
public float number2 = 0;//存储单击=号时TextNum的值
public int n = 0;//记录是击了=键还是未击。
public float M = 0;
public string COPYM = "";
..........................................
..........................................
..........................................
//开平方根:
private void btnSqrt_Click(object sender, EventArgs e)
{
if (TxtNum.Text.Trim() != "")
{
float tempnumber = (float)Math.Sqrt(float.Parse(TxtNum.Text));//Math.Sqrt()结 //果为double型,所以要用float强制转换
TxtNum.Text = tempnumber.ToString();
}
flag = true;
}
//百分号:
private void btnPercent_Click(object sender, EventArgs e)
{
}
//分数:
private void btnFraction_Click(object sender, EventArgs e)
{
}
}