Version 2 (modified by shermanl, 15 years ago) (diff)

--

Create a simple user interface

This article will teach you how to create a Button, Label and a Textbox control.

  1. On the File menu, choose New Project.
  1. In the New Project dialog box, in the Templates pane, click Windows Application.
  1. In the Name box, type TextBoxExample, and then click OK.

A new Windows Forms project opens.

  1. From the Toolbox, drag a TextBox, Label, and Button control onto the form.

  1. Select the Label control and drag it above the TextBox control

  1. In the Properties window, change the Text property of the Label control to the following code.

Enter your name and click the button.

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!

To add code and test your program

  1. Double-click the Button control to open the Code Editor.

The Code Editor opens the Button1_Click event handler.


  1. Add the following line of code to the Button1_Click event handler.
MsgBox("Your Name is " & Textbox1.Text)


  1. Press F5 to run your program.

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

Attachments