Introduction:
Adding, subtraction, multiplication and division of two
numbers with the help of two TextBoxes and result will display in
third TextBox by using window form.
Step 1: Open visual studio--> file menu-->new--> project--> then
Step 2: Take 3 TextBoxes one for
input First number, other for second number and third one is for the
result TextBox. Design the form as follows:
Step 3: Coding
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
Arithmetic
{
public partial
class ArthOperations :
Form
{
public ArthOperations()
{
InitializeComponent();
textBox3.Enabled = false;
}
private void
add(object sender,
EventArgs e)
{
float first;
float second;
float output;
first =
Convert.ToInt32(textBox1.Text);
second =
Convert.ToInt32(textBox2.Text);
output = first + second;
textBox3.Text=(output.ToString());
}
private void
sub(object sender,
EventArgs e)
{
float first;
float second;
float output;
first = Convert.ToInt32(textBox1.Text);
second = Convert.ToInt32(textBox2.Text);
output = first - second;
textBox3.Text = (output.ToString());
}
private
void div(object
sender, EventArgs e)
{
float first;
float second;
float output;
first = Convert.ToInt32(textBox1.Text);
second = Convert.ToInt32(textBox2.Text);
output = first / second;
textBox3.Text = (output.ToString());
}
private void
mul(object sender,
EventArgs e) {
float first;
float second;
float output;
first = Convert.ToInt32(textBox1.Text);
second = Convert.ToInt32(textBox2.Text);
output = first * second;
textBox3.Text = (output.ToString());
}
private void
clear(object sender,
EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
}
}
Step 4- Runnning above code
ADD BUTTON CLICK.
SUB BUTTON CLICK.
DIVISION BUTTON CLICK.
MULTIPLY BUTTON CLICK.