Creating the Project

The first thing to do is create a directory where you will store all your VB project. Call it VBApps, for example. Then start VB. The first screen asks if you want to open a new project or an existing one - it's definitely a new one and will be a Standard EXE. Then, maximize all the windows (it's easier to work with - some examples in the tutorial should be reduced for the sake of presentation). Now, save your project. It will first prompt you to save a form - call Score.frm - and then the project - called Scorebrd.vbp. From now on, do File -> Save Project very, very frequently.
Before you start building-up form, it will make it easier if you change the color of the form. If you will work with the control of gray on a gray background. To change colors, simply click anywhere on the form, go to the properties window, find the property called BackColor and turn it into a standard background window (or real) or to any color you want in the palette.

In the first example, we will need 6 labels and 2 command buttons. Each one of the things you put on the form are called controls. To get the control you go to the Toolbox, click on the control you want, come back to the Form and click and drag the control to the size and position you want. Position control is somewhat like the diagram below.

IMPORTANT NOTE: If this is your first experience with VB, do not be afraid to experiment. This is a hands-on stuff! Remember that VB is a Microsoft product, so it works with standard Windows interface. All the functions you know from MS-Office work the same way here: Copy, Cut, Paste, (Ctrl) + (click), (Shift) + (click), move the mouse controls to select them all, etc. The key Undo is a great way to keep handy - when you change your control can always change Undo - remember this when you get to the part about aligning the controls, making them all the same size and so on. That part can be tricky. If you accidentally end up in the code window while palying around, down a few paragraphs and you will see how to get back into form. At this point the worst that can happen is that the form you will get all messed up. So what! You can only scrap and start over again, but you'll learn something.

Now we have a lot of control on the form, we have them a little jazz. We do this by changing the properties of controls in the Properties window. Each control has a set of properties, which most of us do not need right now. What we need is:
Alignment = how to align text on the control
BackColor = choose a background color
Caption = text that will appear in the control
Font = choose the font type and size
ForeColor = choose a text color (foreground)
As with all Windows applications
, You can select multiple controls with (Ctrl) + (click) and change the properties for them all at once. For example, if all the white background, select all the controls, ForeColor turns white and they are all modified. Change your form to look like below. Note that you do not need to change the Caption to Label4, Label5 and Label6 and that you can not change the color of the button. They demanded that the so-called in the old days "IBM gray". Do not forget to save your project as often as you go along!

If you run the application at this point, you will see your form appear, as you created it. However, if you click on one of control, absolutely nothing happens! There are events that occur; open form, the button is clicked, etc. But, no one tells the form what to do when looking at an event. That is why we have to write code, also called a script.
To switch between windows and the windows form code, use the right button on the Project Explorer window (diagram at left).
Once in the Code window, you have the option to see all the code for the project or the code for one event at a time. Use the buttons at the bottom left corner (diagram at right).
To select objects and events that you want the code, use two Listboxes at the top of the Code. The one on the left to the object and the one on the right for the event. Start with the General. Declaration and then Forms. Load, etc.


At this point you may want to download a sample program and learn it. In the following lesson we will add functionality to exercice and we will explain what the meaning of the code. But for now, a good exercice will write part of the code and then try to find ways to improve certain aspects of the program.

You can download the application here

Now we can run and see something happen. When the form loads, it initializes the fields that we specified in the code.



Penulis : Unknown ~ Sebuah blog yang menyediakan berbagai macam informasi

Artikel Creating the Project ini dipublish oleh Unknown pada hari Jumat, 09 Maret 2012. Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan Creating the Project
 

0 komentar:

Posting Komentar