c#制作简易计算器现在界面完成,跪求源代码:P.S.请说明到底在哪里输入什么代码.谢高手!解决的给高分!
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 10:59:58
c#制作简易计算器现在界面完成,跪求源代码:P.S.请说明到底在哪里输入什么代码.谢高手!解决的给高分!
c#制作简易计算器
现在界面完成,跪求源代码:
P.S.请说明到底在哪里输入什么代码.谢高手!解决的给高分!
c#制作简易计算器现在界面完成,跪求源代码:P.S.请说明到底在哪里输入什么代码.谢高手!解决的给高分!
这是我做的一个简单计算器界面,代码如下:
希望能帮助到你;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 计算器
{
public partial class Form1 : Form
{
char fh;
double number,temp;
private void Form1_Load(object sender, EventArgs e)
{
}
public Form1()
{
InitializeComponent();
}
private void but1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "1";
}
private void but2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "2";
}
private void but3_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "3";
}
private void but4_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "4";
}
private void but5_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "5";
}
private void but6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "6";
}
private void but7_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "7";
}
private void but8_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "8";
}
private void but9_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "9";
}
private void but0_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "0";
}
private void but10_Click_1(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + ".";
}
private void butAdd_Click(object sender, EventArgs e)
{
number = double.Parse(textBox1.Text);
fh = '+';
textBox1.Text = null;
}
private void butMin_Click(object sender, EventArgs e)
{
number = double.Parse(textBox1.Text);
fh = '-';
textBox1.Text = null;
}
private void butMul_Click(object sender, EventArgs e)
{
number = double.Parse(textBox1.Text);
fh = '*';
textBox1.Text = null;
}
private void butDiv_Click(object sender, EventArgs e)
{
number = double.Parse(textBox1.Text);
fh = '/';
textBox1.Text = null;
}
private void buttonDaoShu_Click(object sender, EventArgs e)
{
number = double.Parse(textBox1.Text);
number = 1.0 / number;
textBox1.Text = number.ToString();
fh = ' ';
number = 0;
temp = 0;
}
private void butRev_Click(object sender, EventArgs e)
{
fh = ' ';
number = 0;
temp = 0;
textBox1.Text = null;
}
private void butApp_Click(object sender, EventArgs e)
{
temp = double.Parse(textBox1.Text);
switch (fh)
{
case '+':
number += temp;
break;
case '-':
number -= temp;
break;
case '*':
number *= temp;
break;
case '/':
number /= temp;
break;
}
textBox1.Text = number.ToString();
fh = ' ';
number = 0;
temp = 0;
}
}
}