Controls and Properties / Textboxes vs. Labels
Subtitles of the Movie
In this demonstration I will discuss the differences between text boxes and labels. Generally speaking, labels are used to display information or messages to the user while text boxes are used to accept user input. To begin I will place two labels on the form followed by two text boxes. As you can see the default names for the labels are Labels 3 and 4 respectively. This is because I actually used two labels at the top of the form that were Label 1 and 2 respectively. But I'm going to rename these labels to the appropriate names for each of these labels. So Label 3 I will call First Name Label, remember to use the name of the control, in this case Label in the name of the control itself and I'll rename Label 4 to Last Name Label. And you'll notice that that does not change what the user sees in the label itself, that is the text property of the label. The name property is an internal name for the control that the programmer will reference in code. The text property is what the user actually sees. So for First Name Label, I will change the text property which currently says Label 3 to a message or prompt to the user that says ÒEnter first name.Ó Here you can use spaces and punctuation as appropriate. And likewise the last name label I will change the text property to read ÒEnter last name.Ó Now you see what the user will see when the program is executed. As stated earlier, labels are used to display a message or in this case a prompt for the user to enter something into the text box. Now the text box by default is called Text Box 1 but again, I want to rename this to a more meaningful name for this text box. Since this text box will hold or accept the person's first name, I will call this First Name Text Box. And for the second text box I will call this Last Name Text Box. So now I have my controls renamed appropriately. Let's quickly run the program to see if the text boxes will accept data as you might expect, so the user is prompted to enter their first name and then they are prompted to enter their last name and as you can see, the text boxes are indeed accepting data just fine. So I'll close this project so we can go back and make some modifications to the form design. As you may note, labels by default do not have a border while text boxes do. This can be changed however, if you click on the label and you go to the border style you'll see the default property setting for the border style is None. Click on the drop down arrow within the border style property and you'll see the choices of fixed single or fixed 3D. I'll choose fixed single for the first name label and I will change the border style to the last name label to fixed 3D so you can see the difference. So now the labels do have borders. Typically this is not done but it is an option if you so choose. Likewise, text boxes have borders that can be changed. Again, as you might expect, go to the border style property for the text box, by default it is set to fixed 3D, if you want to change that, you can simply change it to none. And as you can see, the text box is still there but the border particularly at runtime you'll be able to see it a little bit better, is not evident. This movie has demonstrated the basic difference between a text box and a label.
Tutorial Information
| Course: | Microsoft Visual Basic 2005 |
| Author: | Arthur Lee |
| SKU: | 33940 |
| ISBN: | 1-935320-10-6 |
| Release Date: | 2008-11-19 |
| Duration: | 7.5 hrs / 97 lessons |
| Work Files: |
Yes |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 