Discussions

Windows and Tools



The Visual Basic development environment contains these programming tools and windows, with which you construct your Visual Basic programs:

  • Menu bar
  • Toolbars
  • Visual Basic toolbox
  • Form window
  • Properties window
  • Project Explorer
  • Immediate window
  • Form Layout window
     The exact size and shape of the windows depends on how your system has been configured. In Visual Basic 6.0, you can align and attach (dock) the windows to make all the elements of the programming system visible and accessible. You’ll learn how to customize your development environment in Moving, Docking, and Resizing Windows.

Loading and Running a Program

Before you can work with a Visual Basic program, you need to load the program into memory, just as you would load a word processing document in a word processor for editing.

To load a Visual Basic program into memory and run it

  1. On the File menu, click Open Project. The Open Project dialog box appears. With this dialog box, you can open any existing Visual Basic program on your hard disk, attached network drive, CD-ROM, or floppy disk.
  2. If necessary, use the Look In drop-down list box and the Up One Level button to locate the program you want to load. Then, double-click the program name. The project file loads the Visual Basic user interface form, properties, and program code. (Visual Basic project files are distinguished by the .VBP file name extension.)
  3. If the program user interface does not appear, open the Forms folder in the Project window, select the first form, and then click View Object in the Project window. This is an optional but useful step, especially if you want to look at the program user interface in the Form window before you run it.
  4. On the Visual Basic Standard toolbar, click Start to run the program. The toolbox and several of the other windows disappear, and the Visual Basic program starts to run.
  5. On the toolbar, click End when you want to exit the program.
See below to view an illustration of the standard contents of the toolbox.


Form Window

When you start Visual Basic, a default form (Form1) with a standard grid (a window consisting of regularly spaced dots) appears in a pane called the Form window. You can use the Form window grid to create the user interface and to line up interface elements.



Building Interface Elements
To build the interface elements, you click an interface control in the Visual Basic toolbox, and then you draw the user interface element on your form by using the mouse. This process is usually a simple matter of clicking to position one corner of the element and then dragging to create a rectangle the size you want. After you create the element — say, a text box — you can refine it by setting properties for the element. In a text box, for example, you can set properties to make the text boldface, italic, or underlined.

Adjusting Form Size
You can adjust the size of the form by using the mouse — the form can take up part or the entire screen.

Controlling Form Placement
To control the placement of the form when you run the program, adjust the placement of the form in the Form Layout window.



Properties Window

With the Properties window, you change the characteristics (property settings) of the user interface elements on a form. A property setting is a characteristic of a user interface object. For example, you can change the text displayed by a text box control to a different font, point size, or alignment. (With Visual Basic, you can display text in any font installed on your system, just as you can in Microsoft Excel or Microsoft Word.)



Displaying the Properties Window
To display the Properties window, click the Properties Window button on the toolbar. If the window is currently docked, you can enlarge it by double-clicking the title bar. To redock the Properties window, double-click its title bar again.

Properties Window Elements
The Properties window contains the following elements:
  • A drop-down list box at the top of the window, from which you select the object whose properties you want to view or set.
  • Two tabs, which list the properties either alphabetically or by category.
  • A description pane that shows the name of the selected property and a short description of it.
Changing Property Settings
You can change property settings by using the Properties window while you design the user interface or by using program code to make changes while the program runs.



Project Window

A Visual Basic program consists of several files that are linked together to make the program run. The Visual  Basic 6.0 development environment includes a Project window to help you switch back and forth between these components as you work on a project.



 Project Window Components
The Project window lists all the files used in the programming process and provides access to them with two special buttons: View Code and View Object.

Displaying the Project Window
To display the Project window, click the Project Explorer button on the Visual Basic toolbar. If the window is currently docked, you can enlarge it by double-clicking the title bar. To re-dock the Project window, double-click its title bar again.

Adding and Removing Files
The project file maintains a list of all the supporting files in a Visual Basic programming project. You can recognize project files by their .vbp file name extension. You can add individual files to and remove them from a project by using commands on the Project menu. The changes that you make will be reflected in the Project window.

Note: In Visual Basic versions 1 through 3, project files had the .mak file name extension. In Visual Basic versions 4, 5, and 6.0, project files have the .vbp file name extension.

Adding Projects
If you load additional projects into Visual Basic with the File menu Add Project command, outlining symbols appear in the Project window to help you organize and switch between projects.



Code Window

You can create much of your program by using controls and setting properties. However, most Visual Basic programs require additional program code that acts as the brains behind the user interface that you create. This computing logic is created using program statements — keywords, identifiers, and arguments — that clearly spell out what the program should do each step of the way.
You enter program statements in the Code window, a special text editing window designed specifically for Visual Basic program code. You can display the Code window in either of two ways:

  • By clicking View Code in the Project window.
  • By clicking the View menu Code command


Form Layout Window

The Form Layout window is a visual design tool. With it, you can control the placement of the forms in the Windows environment when they are executed. When you have more than one form in your program, the Form Layout window is especially useful — you can arrange the forms onscreen exactly the way you want.

To position a form in the Form Layout window, simply drag the miniature form to the desired location in the window.




Source: EASTERN MEDITERRANEAN UNIVERSITY - MECHANICAL ENGINEERING DEPARTMENT