Home and Learn: VB Net Course
Let's start by adding a textbox to our form.
With the Common Controls displayed, do the following:
The textbox gets added to the top left position of your form. To move it down, hold your mouse over the textbox and drag to a new position:
Notice the small squares around the textbox when you let go of the left mouse button:
The small squares are sizing handles. Move your mouse over one of them. The mouse pointer turns into an extended line with arrowheads. Hold your left mouse button down and drag outwards. The textbox is resized. Play around with the sizing handles until you're happy with the size of your textbox.
One thing you will notice is that you can't make the size any higher, but you can make it wider. The reason why you can't make it any higher is because the default action of a textbox is to have it contain only a single line of text. If it's only going to contain one line of text, Microsoft reasoned, there's no reason why you should be able to change its height. A textbox can only be made higher if it's set to contain multiple lines of text. You'll see how to do this soon.
Let's add some labels near the textboxes so that your users will know what they are for.
Click on the label to select it. Now hold your left mouse button down on the label. Keep it held down and drag it to the left of the textbox.
Create two more labels, and position them to the left of the textboxes. You should now have a form like this one:
To see what your Form looks like as a programme, click Debug > Start from the menu bar. Or press F5 on your keyboard:
To stop the programme from running, you can do one of the following:
1. Click the Red X at the top right of your Form
2. Click Debug > Stop Debugging from the menu bar
3. Press Shift + F5 on your keyboard
You can also click the Stop button on the VB toolbars at the top, as in the image below:
You can also start you project without debugging. Simply click the Start Without Debugging option on the Debug menu. You won't get any of the Diagnostic Tools, but your form will be quicker to start up.
To stop your form from running, click the X in the top right of the form. This will take you back to the Design environment.
All right, we're getting somewhere. We now have a form with textboxes and labels, something that looks like a form people can fill in. But those labels are not exactly descriptive, and our textboxes have the default text in them. So how can we enter our own text for the labels, and get rid of that default text for the textboxes?
To do those things, we need to discuss something called a Property.
Buy the Book of this Course
Email us: enquiry at homeandlearn.co.uk