Jennifer Bell

Jennifer Bell

  • NA
  • 14
  • 13.9k

C# Gui Program

Dec 2 2012 9:03 PM

I am making a C# gui program. It allows the users to input the length, width , and height of the triangular prism. The program will display the volume and surface area of the prism. We are assuming that the ends of the prism are isosceles triangles.

There should be text boxes for the input of the length, width, and height. The values can not be negative. The answers should be outputted to the 2nd decimal place. A compute button is used to preform the calculations. Clear button will clear everything and the exit button will close the program.



 

This is what I have so far. It has a few errors do not know why this is happening.  Any sugguestions would be great. Thanks




 

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

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Exit_Click(object sender, EventArgs e)

        {

            Close();

        }

 

        private void computeButton_Click(object sender, EventArgs e)

        {

            double width = Convert.ToDouble(widthBox.Text);

            double length = Convert.ToDouble(lengthBox.Text);

            double height = Convert.ToDouble(heightBox.Text);

 

            if (width < 0)

            { MessageBox.Show ("Value cannot be negative!");

              width.Focus();

              width.ResetText();

            }

            else

            if (length < 0)

            { MessageBox.Show ("Value cannot be negative!");

              length.Focus();

              length.ResetText();

            }

            else

                if (height < 0)

                {

                    MessageBox.Show("Value cannot be negative!");

                    height.Focus();

                    height.ResetText();

                }

                else

                {

                    //formulas here?

                  

                }

        }

 

        private void clearButton_Click(object sender, EventArgs e)

        {

            widthBox.Text = "";

            lengthBox.Text = "";

            heightBox.Text = "";

            volume.Text = "";

            surfaceArea.Text = "";

        }

    }

}

v


Answers (1)