Last week, we wound up creating a simple application which could accept user input and show it back to the user in a message box. Today, we’ll be taking those concepts and moving forward with them to do more useful things. We will start with creating a simple application which access two numbers, adds those numbers together, and displays the result to the user.
1. Open Visual C# Express and create a new WinForms application named “SimpleAdder”
2. In your form, add a TextBox from the toolbox and change its name to “numberOneBox”
3. Add another TextBox and change its name to “numberTwoBox”
4. Add another TextBox and change its name to “resultBox”
5. Add a button and change its name to “addButton” and change the Text property of the button to “Add”
6. Add appropriate label controls and arrange the controls on the screen in a way that makes sense to you.
7. Double click the Add button so that you can put code into the Click event.
8. In the Click event, change the resultBox’s Text property to reflect the addition of numberOneBox’s Text property and numberTwoBox’s Text property.
9. Run your application and see what the results are like.
Hint: If you’ve followed these instructions explicitly, you will have an application which does not function as you expect. We’ll correct the behavior once everyone has reached this point.