none
How do I multiply a number by pi

    Question

  • Hey,
    I'm currently programming a calculator application and I have found myself stuck on multiplying a number by the mathmatical value of PI.  The number shall be inputted in to a textbox1 and the result shall be shown in textbox2.  Does anyone have a solution to this?

    All replys are appreciated
    regards Liam
    Sunday, December 11, 2005 12:59 AM

Answers

All replies

  • try System.Math.PI
    that should help.
    Sunday, December 11, 2005 2:37 AM
  • Thanks,
    I'm not that experianced would you mind putting it in example for me.  As I am not aware of how to use this sorry if this sounds a little lame.

    regards Liam
    Sunday, December 11, 2005 2:40 AM
  • No problem. :)



    double answer;
    double mynumber = 10;
    answer = mynumber * System.Math.PI;

     


    That will multiply 10 and PI and put into variable answer.
    Sunday, December 11, 2005 2:49 AM
  • Thanks a lot Justin that worked just fine.
    Sunday, December 11, 2005 2:51 AM
  • I am also having problems showing the results of this calculation as I am retrieving the number to multiply from a textbox named textbox1. 


    double answer;

    double mynumber = textBox1.Text;

    answer = mynumber * System.Math.PI;



     


    What would be the best way to convert this and show my message in the same textbox removing the inputted number.

    Regards Liam
    Sunday, December 11, 2005 3:17 AM
  • textBox1.Text = answer.toString();
    Sunday, December 11, 2005 4:02 AM
  • Still having problems converting.


    double answer;

    double mynumber = textBox1.Text;

    answer = mynumber * System.Math.PI;

    textBox1.Text = answer.toString();


     


    I tried:


    mynumber = double.Parse(textBox1.Text);

     


    But this also had problems implicitly converting.
    Thanks a lot for all the help so far
    regards Liam
    Sunday, December 11, 2005 5:41 AM
  • It's like this in C#:

    mynumber = Convert.ToDouble(textBox1.Text);

    Sunday, December 11, 2005 5:06 PM
  • Here's the full answer.



    double answer;

    double mynumber = Convert.ToDouble(textBox1.Text);

    answer = mynumber * System.Math.PI;

    textBox2.Text = answer.ToString();


     

    Monday, December 12, 2005 10:34 PM