Home and Learn: VB Net Course

The Text Property of a Control

Changing the values of some properties is fairly easy. We'll now change the Text properties of our labels, and the Text properties of our Textboxes.

Click on Label1 so that it has the sizing handles, and is therefore selected. Examine the Property box for the Label:

Label Property in VB NET

You can see that the Label control has quite a few different properties to the Form control. Think back to your television as an control. It will have different buttons and knobs to your DVD Player control. A label has different "buttons and knobs" to the Form's "buttons and knobs".

But the Label has a lot of properties that are the same. The Text property of a Label does what you'd expect it to do: adds text to your label. We'll do that now:

  1. With label1 selected, click inside the area next to "Text", and delete the word "Label1" by hitting the backspace key on your keyboard
  2. Type in the words "First Name"
  3. Click back onto the grey form, or hit the return key on your keyboard
  4. Label1 has now changed its text caption to read "First Name"
  5. If you've made a typing error, go back to the first step above and try again
  6. Your form should now look like this:

Now, change the Text property of the other two labels. Change them to these values:

Label2: Last Name
Label3: Telephone Number

What you should notice is that the labels resize themselves, after you press the enter key to commit the changes. You may need to drag your labels to the left a bit. But when you're finished, your form should look like ours below:

The form might look a little squashed, though. Is there anything we can do to make it bigger? Well, it just so happens there is.

The Form can be resized just like the Label and the textboxes. Click anywhere on the form that is not a textbox or a label. If you look closely around the Form's edges, you'll notice our old friends the sizing handles. To make the form bigger, just stretch them like you did the labels and the textboxes. Play around with the size of the form until you're happy with it. You can now reposition and resize the textboxes and labels so that things don't look too squashed. Your form might look like this one:

Form Resized

Click on Debug > Start to have a look at your programme. Or Press F5 on your keyboard. Click Debug > Stop Debugging to get back to the design environment. (Or press Shift + F5, or just click the red X at the top right of the form.)

Now, lets add a splash of colour to our form.

Back to the VB NET Contents Page


Buy the Book of this Course

Email us: enquiry at homeandlearn.co.uk