Your First Visual Basic Project

Your First Visual Basic Project 







Your First Visual Basic Project














Launch your Visual Basic .NET or Visual Studio software. When the software first loads


There's a lot happening on the start page. But basically, this is where you can start a new project, or open an existing one. The first Tab, Projects, is selected. At the moment, the area labelled "Open an Existing Project" is blank. This is what you'll see when you run the software for the first time (because you haven't created a project yet). When you create a project, the Name you gave it will be displayed on this page, as a hyperlink. Clicking the link will open the project.

At the bottom of the screen, there are two buttons: "New Project" and "Open Project". To get started, click the "New Project" button. When you do, you'll see this dialogue box appear:

As a beginner, you'll normally want the option selected: "Windows Application", in the "Visual Basic Projects" folder. This means that you're going to be designing a programme to run on a computer running the Microsoft Windows operating system.

If you look in the Name textbox at the bottom, you'll see it says "WindowsApplication1". This is the default name for your projects. It's not a good idea to keep this name. After all, you don't want all of your projects to be called "WindowsApplication1", "WindowsApplication2", etc. So click inside this textbox and change this Name to the following:

My First Project
Keep the Location the same as the default. This is a folder inside of your "My Documents" folder called "Visual Studio Projects". A new folder will then be created for you, and its name will be the one you typed in the "Name" textbox. All of your files for your first project are then saved in this folder.

Click the OK button, and the Visual Basic NET design time environment will open. It will look like the following (the 2008 edition is just the same):

The Form:
In the Visual Basic NET design time environment, the first thing to concentrate on is that strange, big square in the top left. That's called a form.
What is actually form is?
Form is an object or precisely you can say that Form is a container object. It is used to hold different kind of objects like buttons, textboxes and labels etc.

To run the form, try this:
· From the menu bar, click Debug
· From the drop down menu, click Start
OR
· Alternatively, press the F5 key on your keyboard
· Your programme is launched

Congratulations! You have now created your very first programme. It should look like this:

If you compare the first form with the one when you create a new application, you'll see that they look very similar.

 So what's going on? Why the two different views? Well, Visual Basic has two distinct environments, a Design environment and a Debug environment.

Design Time: Design Time is where you get to play about with the form, spruce it up, add textboxes, and buttons, and labels (and code, of course).

Debug / Run Time: Debug is where you can test your programme and see how well it performs.

But don't worry about the terminology, for the time being. Just be aware that there's a two step process to VB programming: designing and debugging.

Adding Controls Using the Toolbox:

Things like buttons, textboxes, and labels are all things that you can add to your Forms. They are know as Controls, and are kept in the Toolbox for ease of use.
The Toolbox can be found on the left of the screen. In the picture below, you can see the toolbox icon next to Form1: (If it is not there then you can add it from the View menu for standard menu bar)


To display all the tools, move your mouse over the toolbox icon. You'll see the following automatically appear:


There are different categories of tools available like Common controls, Containers, Date and Dialog etc. (You can add your own category and I shown this to you in the class). The toolbox you'll be working with first is the Common Controls toolbox. To see the tools, click on the plus symbol next to Common Controls. You'll see a long list of tools: (Due to shortage of space I am presenting this picture in rotate form)


If you want to keep the toolbox displayed, click the Pin icon next to the X. To close the toolbox, simply move your mouse away.

How to Add a Control to your VB .NET Forms:
Let's start by adding a textbox to our form. With the tools displayed, do the following:

· Locate the TextBox tool
· Double click the icon
· A textbox is added to your form

Note: I showed two another method of adding controls to the form in class.

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

Note: The same handles you can find on form as well. Just click the form and notice the handles. You can move it to and fro in order to resize the form.

· Create two more textboxes by double clicking on the textbox icon in the toolbar (Or Right-click on the selected textbox and choose Copy. Then Right-click on the Form and choose Paste.)
· Resize them to the same size as your first one
· Line them up one below the other with space in between
· Try to create something that looks like the one below......







Download Your First Visual Basic Project / PDF
















Your First Visual Basic Project 

0 commentaires: