User Input
As we have now written some text asking the user (the person using
the program) for his or her name, we need to give them somewhere to type it.
To do this we use the TextBox control. This is the
icon in the Toolbox. Just like before, select this icon, and add the textbox
to your form, next to the 'Please enter your name' text. Again, we can use the
Properties window to change a few things. First, rename the textbox to txtName
(as txt is the conventional prefix for textboxes). The other thing we need to
change is its Text property; because the user needs to enter some text,
the textbox needs to start out empty, rather than having 'Text1' displayed in
it. To do this, scroll down to the Text property in the Property Window, and
delete the text.
By now, your form should look something like this:
For the next stage you need to add one more control; the CommandButton
control. This simply a button that the user can click, in this case to say that
he/she has entered their name. To add the control, click the
icon, and add the control to your form, next to the text box. Name this control
cmdOK, and set its Caption property to 'OK'.
You will notice that to change the text on a control, sometimes
the property is called Caption, and sometimes it is called Text. The reason
for this is that in a Text box, a user can change what appears in it (and therefore
it is Text). On a button or label control however, the text is static.
This means that it cannot be changed by the user.