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
{
public Form1()
{
InitializeComponent();
}
public string flag; private void button5_Click(object sender, EventArgs e)
{
if (flag == "+")
{ int a = int.Parse(this.textBox1.Text);
int b = int.Parse(this.textBox2.Text);
this.textBox3.Text = (a + b).ToString(); }
if (flag == "-")
{
int a = int.Parse(this.textBox1.Text);
int b = int.Parse(this.textBox2.Text);
this.textBox3.Text = (a - b).ToString();
} if (flag == "*")
{ int a = int.Parse(this.textBox1.Text);
int b = int.Parse(this.textBox2.Text);
this.textBox3.Text = (a * b).ToString(); }
if (flag == "/")
{ int a = int.Parse(this.textBox1.Text);
int b = int.Parse(this.textBox2.Text);
this.textBox3.Text = (a / b).ToString(); }
} private void button1_Click(object sender, EventArgs e)
{
flag = (sender as Button).Text;
} private void button2_Click(object sender, EventArgs e)
{
flag = (sender as Button).Text;
} private void button3_Click(object sender, EventArgs e)
{
flag = (sender as Button).Text;
} private void button4_Click(object sender, EventArgs e)
{
flag = (sender as Button).Text;
}
}
}
简单小计算器
最新推荐文章于 2024-03-03 18:26:04 发布