Calculator Using Radio Button In C# Using Windows Form Application
Steps To Perform Addition Of Two Numbers In C# Using Windows Form Application
Step No 1 :- Open Microsoft Visual Studio(version : In My Case 2015).
Step No 2 :- Click On File, Select New, Then Click On Project.
Step No 3 :- Now, Here A New Window Will Appear, Now Give A Name According To Your Choice And Also Select Windows Form Application.
Step No 4 :- A New Form Will Appear.
Step No 5 :- At Left Position A toolbox Will Be There Using That Toolbox You Can Easily Add Tools For Your Windows Form Application.
Step No 6 :- Now Drag & Drop Tools From Toolbox.
Step No :- 7 Now Using Label, Text-box & Button Make A Form Of Addition As Showed in Given Image
Step No 8 :- Now Double-Click On Total Button Because We Have To Perform Calculation(Arithmetic Operations) When A User Click On Total Button.
Step No 9 :- Now Write This Code Which Is Given Below.
private void button1_Click(object sender, EventArgs e)
{
int a, b, c;
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
if (radioButton1.Checked)
{
c = a + b;
textBox3.Text = c.ToString();
}
else if (radioButton2.Checked)
{
c = a - b;
textBox3.Text = c.ToString();
}
else if (radioButton3.Checked)
{
c = a * b;
textBox3.Text = c.ToString();
}
else if (radioButton4.Checked)
{
d = a / b;
textBox3.Text = d.ToString();
}
{
c = a + b;
textBox3.Text = c.ToString();
}
else if (radioButton2.Checked)
{
c = a - b;
textBox3.Text = c.ToString();
}
else if (radioButton3.Checked)
{
c = a * b;
textBox3.Text = c.ToString();
}
else if (radioButton4.Checked)
{
d = a / b;
textBox3.Text = d.ToString();
}
}
Step No 10. Now Click On Start As Showed In Given Image.
Output :-
For More Queries Please Comment.
Comments
Post a Comment