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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
text_all();
TextChanged_all();
}
private void txt_TextChanged(object sender, EventArgs e)
{
try
{
double n = double.Parse(textBox1.Text) + double.Parse(textBox2.Text);
textBox3.Text = n.ToString();
}
catch (Exception ex)
{ }
}
private void txt_TextChanged1(object sender, EventArgs e)
{
try
{
double n = double.Parse(textBox4.Text) - double.Parse(textBox5.Text);
textBox6.Text = n.ToString();
}
catch (Exception ex)
{ }
}
private void txt_TextChanged2(object sender, EventArgs e)
{
try
{
double n = double.Parse(textBox7.Text) * double.Parse(textBox8.Text);
textBox9.Text = n.ToString();
}
catch (Exception ex)
{ }
}
private void txt_TextChanged3(object sender, EventArgs e)
{
try
{
double n = double.Parse(textBox10.Text) / double.Parse(textBox11.Text);
textBox12.Text = n.ToString();
}
catch (Exception ex)
{ }
}
private void text_all()
{
textBox1.Text = "0";
textBox2.Text = "0";
textBox3.Text = "0";
textBox4.Text = "0";
textBox5.Text = "0";
textBox6.Text = "0";
textBox7.Text = "0";
textBox8.Text = "0";
textBox9.Text = "0";
textBox10.Text = "0";
textBox11.Text = "0";
textBox12.Text = "0";
}
private void TextChanged_all()
{
textBox1.TextChanged += new EventHandler(txt_TextChanged);
textBox2.TextChanged += new EventHandler(txt_TextChanged);
textBox3.TextChanged += new EventHandler(txt_TextChanged);
textBox4.TextChanged += new EventHandler(txt_TextChanged1);
textBox5.TextChanged += new EventHandler(txt_TextChanged1);
textBox6.TextChanged += new EventHandler(txt_TextChanged1);
textBox7.TextChanged += new EventHandler(txt_TextChanged2);
textBox8.TextChanged += new EventHandler(txt_TextChanged2);
textBox9.TextChanged += new EventHandler(txt_TextChanged2);
textBox10.TextChanged += new EventHandler(txt_TextChanged3);
textBox11.TextChanged += new EventHandler(txt_TextChanged3);
textBox12.TextChanged += new EventHandler(txt_TextChanged3);
}
}
}
沒有留言:
張貼留言