| 1 | = Create a simple user interface = |
| 2 | This article will teach you how to create a Button, Label and a Textbox control. |
| 3 | |
| 4 | 1. On the File menu, choose New Project. |
| 5 | |
| 6 | |
| 7 | 2. In the New Project dialog box, in the Templates pane, click Windows Application. |
| 8 | |
| 9 | |
| 10 | |
| 11 | 3. In the Name box, type !TextBoxExample, and then click OK. |
| 12 | |
| 13 | A new Windows Forms project opens. |
| 14 | |
| 15 | |
| 16 | |
| 17 | 4. From the Toolbox, drag a !TextBox, Label, and Button control onto the form. |
| 18 | |
| 19 | |
| 20 | |
| 21 | 5. Select the Label control and drag it above the !TextBox control |
| 22 | |
| 23 | |
| 24 | |
| 25 | 6. In the Properties window, change the Text property of the Label control to the following code. |
| 26 | |
| 27 | Enter your name and click the button. |
| 28 | |
| 29 | |
| 30 | |
| 31 | Now that you have created a basic user interface, you will need to add a little bit of code to your program, and then it will be ready to test! |
| 32 | |
| 33 | |
| 34 | |
| 35 | == To add code and test your program == |
| 36 | |
| 37 | 1. Double-click the Button control to open the Code Editor. |
| 38 | |
| 39 | |
| 40 | |
| 41 | The Code Editor opens the Button1_Click event handler. |
| 42 | |
| 43 | |
| 44 | |
| 45 | 2. Add the following line of code to the Button1_Click event handler. |
| 46 | |
| 47 | |
| 48 | {{{ |
| 49 | MsgBox("Your Name is " & Textbox1.Text) |
| 50 | }}} |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | 3. Press F5 to run your program. |
| 56 | |
| 57 | |
| 58 | |
| 59 | 4. When the form appears, type your name in the !TextBox control and click the button. A message box appears, displaying the text in the !TextBox control. Change the text and click the button again. Each time you click the button, the updated text is displayed. |
| 60 | |
| 61 | |