3 Replies - 3353 Views - Last Post: 08 January 2010 - 08:12 AM Rate Topic: -----

#1 gotagoJOE  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 12-June 09

changing c# console app to windows form

Post icon  Posted 08 January 2010 - 06:03 AM

public class floorarea 
{ 
   public static void Main() 
	{ 
	  double length, width, area; 
	  string strLength, strWidth; 
		
	   System.Console.Out.Write( "Enter length of room: "); 
		strLength = System.Console.Readline(); 
		length = System.Convert.ToDouble(strLength); 
		System.Console.Out.Write( "Enter width of room: "); 
		strWidth = System.Console.Readlin(); 
		width = System.Convert.ToDouble(strWidth); 
	   //calculate area 
		 area = length * width; 
	  System.Console.Out.Writeline("the area is " + area); 



I want to have this program work on a windows form- using viusal studio C# express- have three textboxes and button.
I want input lenth and width into first two buttons and make calculation in button to have area display in third textbox.
have tried changing strLength = System.Console.Readline();
to strLength = textBox1.text and same with width-
and make third statement textBox3.text = String.Format( " the area is {0}, area);
but getting errors
can you point any obvious errors I am doing
thank you

Is This A Good Question/Topic? 0
  • +

Replies To: changing c# console app to windows form

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: changing c# console app to windows form

Posted 08 January 2010 - 06:26 AM

Could it be this? You are using:

textBox3.text = String.Format( " the area is {0}, area); 



Should be:

textBox3.Text = String.Format( " the area is {0}", area); 



You missed a double quote. If this is not the case, then what errors are you getting?
Was This Post Helpful? 0
  • +
  • -

#3 Adkins  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 66
  • View blog
  • Posts: 560
  • Joined: 27-October 09

Re: changing c# console app to windows form

Posted 08 January 2010 - 06:59 AM

public class floorarea
{
   public static void Main()
    {
     double length, width, area;
     string strLength, strWidth;

     length = double.Parse(TextBox1.Text, System.Globalization.NumberStyles.Float);
     width = double.Parse(TextBox2.Text, System.Globalization.NumberStyles.Float);

     //calculate area
     area = length * width;
     TextBox3.Text = "The area is " + area;
    }
}



Try that to get you started.
Was This Post Helpful? 1
  • +
  • -

#4 gotagoJOE  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 12-June 09

Re: changing c# console app to windows form

Posted 08 January 2010 - 08:12 AM

thank you- I am going to work on that and I will get back if any more questions
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1