//************************************** // Name: Area of Rectangle in C# // Description:Here is a another simple program that I wrote in C# to ask the user to give the length and breath of the rectangle and the our program will compute for its area. I am using Visual Studio 2010 Ultimate Edition in this program. Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360. // By: Jake R. Pomperada // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //************************************** 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 button1_Click(object sender, EventArgs e) { int length= 0, breadth=0,solve_area=0; if (!int.TryParse(textBox1.Text, out length)) { MessageBox.Show("I need just a number in the textbox."); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } else if (!int.TryParse(textBox2.Text, out breadth)) { MessageBox.Show("I need just a number in the textbox."); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } else { length = Convert.ToInt32(textBox1.Text); breadth = Convert.ToInt32(textBox2.Text); solve_area = (length * breadth); label5.Text = "The Area of the Rectangle is " + solve_area + "."; } } private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; label5.Text = " "; textBox1.Focus(); } } }