Em click vào các button thì toàn bị như trong hình
namespace CTNC2
{
public partial class Form1 : Form
{
public System.Windows.Forms.TextBox tbtoantu1;
public System.Windows.Forms.TextBox tbtoantu2;
public System.Windows.Forms.TextBox tbketqua;
public Form1()
{
InitializeComponent();
}
protected void Form1_Load(object sender, EventArgs e)
{
}
protected void cong_Click(object sender, EventArgs e)
{
int toantu1 = Int32.Parse(tbtoantu1.Text);
int toantu2 = Int32.Parse(tbtoantu1.Text);
int ketqua = toantu1 + toantu2;
tbketqua.Text = ketqua.ToString();
}
protected void tru_Click(object sender, EventArgs e)
{
int toantu1 = Int32.Parse(tbtoantu1.Text);
int toantu2 = Int32.Parse(tbtoantu2.Text);
int ketqua = toantu1 - toantu2;
tbketqua.Text = ketqua.ToString();
}
protected void nhan_Click(object sender, EventArgs e)
{
int toantu1 = Int32.Parse(tbtoantu1.Text);
int toantu2 = Int32.Parse(tbtoantu1.Text);
int ketqua = toantu1 * toantu2;
tbketqua.Text = ketqua.ToString();
}
protected void chia_Click(object sender, EventArgs e)
{
int toantu1 = Int32.Parse(tbtoantu1.Text);
int toantu2 = Int32.Parse(tbtoantu1.Text);
if (toantu2 == 0)
{
tbketqua.Text = "ERROR";
}
else
{
double ketqua = (double)toantu1 / toantu2;
tbketqua.Text = ketqua.ToString();
}
}
private void thoat_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}