Question
I'm using C# to make a Windows Form Application. My form has 4 labels, 4 text boxes, 2 buttons. I'm having trouble getting the area
I'm using C# to make a Windows Form Application. My form has 4 labels, 4 text boxes, 2 buttons. I'm having trouble getting the area and perimeter. When I enter length and width and push calculate button, nothing shows in textbox for area and perimeter. Can you please explain what I'm doing wrong. This is my event handler code for my calculate button:
private void btnCalculate_Click(object sender, EventArgs e) {
double length, width,area,perimeter;
length = Convert.ToDouble(txtLength.Text);
width = Convert.ToDouble(txtWidth.Text);
area = length * width;
perimeter = (2 * length + 2 * width);
String txtArea = Convert.ToString(area);
btnCalculate.Text = Convert.ToString(perimeter);
Console.WriteLine(txtArea);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started