Designing The Visual Interface Form |
|
The first step in Visual Basic application is to create the forms that will be the basis for your application' s interface .It comprises of two Steps: |
|
1. Placing Controls on the form. |
2. Setting Properties of Controls at Design Time. |
|
Placing Controls on the form: |
|
The following method will guide you about placing controls on the form. |
A window will appear when you start Visual Basic.Main window will look like that: |
|
|
|
Select the Standard EXE from the above figure.Now you will see the following figure: |
|
|
|
As you have read earlier above window is the main VISUAL BASIC IDE ,all application are created in the IDE.The above IDE will contain six windows: |
|
I. Main Window |
II. Form Window |
III. Tool Box |
IV. Property Window |
V. Form Layout Window |
VI. Project Explorer Window |
|
Note That: |
If any of the above is not present in the IDE then you can invoke them by selecting from view menu. |
|
|
|
The user interface is 'drawn' in the form window. |
|
There are two ways to place controls on a form: |
|
1. Double-click the tool in the toolbox and it is created with a default size on the form. You can then move it or resize it. |
|
2. Click the tool in the toolbox, and then move the Mouse pointer to the form window. The cursor changes to a crosshair. |
Place the crosshair where you want the control at form by pressing the left mouse button and hold it down while dragging the cursor. |
When you release the mouse button the control is drawn. This approach must be used to place controls in a frame or picture box control. |
|
For example you have to place a textbox control to the form, follow these steps: |
|
Select the text box control from the tool box by clicking on it. when selected it will appear like figure: |
|
|
|
3.Click and drag within 'Form1' to place the TextBox at the form. 'Text box' control has a default text 'Text1'. |
|
Note that: |
Drag the mouse while keeping the left mouse button pressed. |
|
Refer to figure: |
|
|
|
So like 'Text Box' control, all other controls can be placed on the form. All have default names. |
|
To resize a control, click the object so that it is select and sizing handles appear. Use these handles to resize the object. |
|
|
|
Setting Properties of Controls at Design Time |
|
Each control has properties assigned to it by default when you start a new project. There are two ways to display the properties of a control. |
|
Þ The first way is to click on the control in the form window. Then click on the Properties Window. |
Þ The second way is to first click on the Properties Window. Then select the object from the Object box in the Properties Window. |
|
Following figure Shows the Properties Window for a new application: |
|
|
|
A very important property for each objects is its name. The name is used by Visual Basic to refer to a particular object in code: |
|
A convention has been established for naming Visual Basic objects. This convention is to use a three-letter prefix (depending on the object) followed by a name you assign. |
|
A few of the prefixes are (you will see more as you progress in course): |
|
Object | Prefix | Example | Form | Form | frmWatch | Command | cmd | cmdExit | Button | btn | btnStart | Label | lbl | lblStart | Text Box | txt | txtTime | Menu | mnu | mnuExit | Check box | chk | chkChoice | Data control | dat | datExample | |
|
No comments:
Post a Comment