主题:我刚写了一个编写计算器的代码,但是调试的时候出现了问题,请老师们给我指点
我刚写了一个编写计算器的代码,但是调试的时候出现了问题,请你给我指点
// Insert page code here
//
void Button1_Click(object sender, EventArgs e)
{
edit1.Text = edit1.Text +'1';
}
void Button2_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'2';
}
void Button3_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'3';
}
void Button4_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'4';
}
void Button5_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'5';
}
void Button6_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'6';
}
void Button7_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'7';
}
void Button8_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'8';
}
void Button9_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'9';
}
void Button0_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'0';
}
void Button12_Click(object sender, EventArgs e) {
edit1.Text="";//清除文本框
}
void Button13_Click(object sender, EventArgs e) {
//int n=1;//为加法变量设置标志变量
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button14_Click(object sender, EventArgs e) {
//int n=2;
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button15_Click(object sender, EventArgs e) {
//int n=3;
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button16_Click(object sender, EventArgs e) {
//int n=4;
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button11_Click(object sender, EventArgs e) {
double temp2;
string temp1;
Button PressedButton = (Button)sender;
switch (PressedButton.ID)
{
case "Button13":
temp2 = Convert.ToDouble(temp1)+Convert.ToDouble(edit1.Text);
case "Button14":
temp2 = Convert.ToDouble(temp1)-Convert.ToDouble(edit1.Text);
case "Button15":
temp2 = Convert.ToDouble(temp1)*Convert.ToDouble(edit1.Text);
case "Button16":
temp2 = Convert.ToDouble(temp1)/Convert.ToDouble(edit1.Text);
}
edit1.Text=temp2.ToString();
}
// Insert page code here
//
void Button1_Click(object sender, EventArgs e)
{
edit1.Text = edit1.Text +'1';
}
void Button2_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'2';
}
void Button3_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'3';
}
void Button4_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'4';
}
void Button5_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'5';
}
void Button6_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'6';
}
void Button7_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'7';
}
void Button8_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'8';
}
void Button9_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'9';
}
void Button0_Click(object sender, EventArgs e) {
edit1.Text = edit1.Text +'0';
}
void Button12_Click(object sender, EventArgs e) {
edit1.Text="";//清除文本框
}
void Button13_Click(object sender, EventArgs e) {
//int n=1;//为加法变量设置标志变量
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button14_Click(object sender, EventArgs e) {
//int n=2;
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button15_Click(object sender, EventArgs e) {
//int n=3;
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button16_Click(object sender, EventArgs e) {
//int n=4;
string temp1;
temp1=edit1.Text;
edit1.Text="";
}
void Button11_Click(object sender, EventArgs e) {
double temp2;
string temp1;
Button PressedButton = (Button)sender;
switch (PressedButton.ID)
{
case "Button13":
temp2 = Convert.ToDouble(temp1)+Convert.ToDouble(edit1.Text);
case "Button14":
temp2 = Convert.ToDouble(temp1)-Convert.ToDouble(edit1.Text);
case "Button15":
temp2 = Convert.ToDouble(temp1)*Convert.ToDouble(edit1.Text);
case "Button16":
temp2 = Convert.ToDouble(temp1)/Convert.ToDouble(edit1.Text);
}
edit1.Text=temp2.ToString();
}