Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C# program to read number from textbox?

im new to C#. I want to know the code for a windows executable program that would accept a number from a textbox and display its square on other textbox. Please tell me how to do that....

2 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    Start building a project in C#. Choose Windows Application. Drag 2 textboxes and a button on the default form. Set the name of the input textbox to txtX and the name of the output textbox to txtX2. You may set the text of the button to "run" or to "^2". Double click the button. The source code is displayed in editor. Type this:

    txtX2.Text = Math.Pow( Convert.ToDouble(txtX.Text), 2).ToString();

    where txtX is the name of the input textbox and txtX2 is the name of the output textbox.

    After compiling, when you click on the button the result should appear in the output textbox

  • 1 decade ago

    check out http://www.pscode.com/ for great sample codes.

Still have questions? Get your answers by asking now.