Friday, July 31, 2009

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....

C# program to read number from textbox?
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
Reply:check out http://www.pscode.com for great sample codes.


No comments:

Post a Comment