To stop the programme from running, you can do one of the following:

6:22 AM / Posted by Alagan /

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

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.
You have noticed the area to the right of the design environment, the area with all the textboxes in a grid, the one that has those daunting names like "AccessibleDescription", "AccessibleName", "AccessibleRole". That's the Properties box.
Click anywhere on the form that is not a label or a textbox, somewhere on the form's grey areas. The form should have the little sizing handles now, indicating that the form is selected.
On the right of the design environment there should be the following Properties box:

If your Properties box says "Textbox1 Textbox" or "Label1 Label" then you haven't yet selected the Form. Click away from the textbox or label until the Properties box reads "Form1 Form"
What you are looking at is a list of the properties that a form has: Name, , BackColor, Font, Image, Text, etc. Just to the right of these properties are the values for them. These values are the default values, and can be changed. We're going to change the value of the Text property.
First, you might want to display the list of Properties in a more accessible form. You can display the list properties alphabetically. To do that, click the Alphabetic icon at the top of the Properties box, as in the image below

This will make the properties easier to find.
Before we change any in the Properties box, let's clear up what we mean by "Property".
What is a Property?
Those controls you added to the form (textboxes and labels), and the form itself, are called control objects. You can think of controls as things, something solid that you can pick up and move about. Controls (things) have properties. If your television were a control, it too would have properties: an On/Off button property, a colour property, a volume property, and a ... well, what other properties would your television have? Think about it.
The properties of your television will have values. The On/Off button would have just two values - On or Off. The volume property could have a range of values, from zero to ten, for example. If the value of the volume property was set to ten, the loudest value, then you'd probably have some very angry neighbours!
In VB.NET, you can change a property of a control from the Properties Box. (You can also change a property using code, which you'll do quite a lot.) If we go back to our Form object, and the properties and values it has, we can see how to change them using the Properties Box. We'll change only one of these values for now - the value of the Text property . So, do this:
•Locate the word "Text" in the Property box, as in the image below

"Text" is a Property of Form1. Don't be confused by the word "Form1" next to the word "Text". All this means is that the current value of the Text property is set to the word "Form1". This is the default.
To change this to something of your own, do this:
•Click inside the area next to "Text", and delete the word "Form1" by hitting the backspace key on your keyboard
•When "Form1" has been deleted, type the words "My First Form"

•Click back on the form itself (the one with the labels and textboxes), or hit the return key on your keyboard
•The words "My First Form" will appear as white text on a blue background at the top of the form

As you can see, your new text has gone at the top of the form, in white on the blue background.
So the Text Property of a form is for setting the caption you want to display in the title bar at the top.
The Text Property
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:
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:
•With label1 selected, click inside the area next to "Text", and delete the word "Label1" by hitting the backspace key on your keyboard
•Type in the words "First Name"
•Click back onto the grey form, or hit the return key on your keyboard
•Label1 has now changed its text caption to read "First Name"
•If you've made a typing error, go back to the first step above and try again
•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
When Label3 has been changed, you might notice that the words "Telephone Number" won't fit on to the Label. That's because the label is too small, and needs to be resized. Drag the sizing handles out until you see both the words.
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:

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

Saving your work
If you have a look in the top right of the Design Environment, you'll see the Solution Explorer. (If you can't see it, click View > Solution Explorer.)

The Solution Explorer shows you all the files you have in your project (Notice that the name of your project is at the top of the tree - "My First Project"). But this is not the whole story. When you save your project, a lot of other files are also created. If you use Windows Explorer (part of the Windows Operating system, and not the VB NET software), you can see all those files

If you wanted to open up your project from here, you would double click the file called "First Form.vbproj".
In Visual Basic .NET an awful lot more files are created for a project than there are with Visual Basic 6. This is due to the Object Oriented nature of NET.
To actually save your work as you go along, do one of the following:
•Click File > Save All from the menu bar
•Press Ctrl + Shift + S on your keyboard
•Click the icon in the Toolbar (the stack of floppy disks)
If you save often then you won't lose any of your work if anything goes wrong with your computer.

Variables are used to store data. A variable has a name to which we refer and the data type, the type of data the variable holds. VB .NET now needs variables to be declared before using them. Variables are declared with the Dim keyword. Dim stands for Dimension.

Data Types in VB .NET
The Data types available in VB .NET, their size, type, description are summarized in the table below.
Access Specifiers
Access specifiers let's us specify how a variable, method or a class can be used. The following are the most commonly used one's:
Public: Gives variable public access which means that there is no restriction on their accessibility
Private: Gives variable private access which means that they are accessible only within their declaration content
Protected: Protected access gives a variable accessibility within their own class or a class derived from that class
Friend: Gives variable friend access which means that they are accessible within the program that contains their declaration
Protected Friend: Gives a variable both protected and friend access
Static: Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends
Shared: Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure
ReadOnly: Makes a variable only to be read and cannot be written



Post a Comment