Myvbprog
Myvbprog
The New Project dialog allows the programmer to choose what type of Visual Basic
program to create. Standard EXE, which is highlighted by default, allows the programmer to
create a standard executable. Each type listed in Fig.(2-2) describes a group of related files
called a Project.
1
Lecture 3... Visual Basic 6.0
Main
window
Project
Window
Form
window
Properties
Window
Toolbox `
Controls
Form
Layout
Code Window
window
1- Main Window: as shown in Fig. (2-4) consists of the title bar, menu bar, and
toolbar:
The title bar indicates the project name, the current Visual Basic operating
mode, and the current form.
The menu bar has drop-down menus from which you control the operation
of the Visual Basic environment, which Contains a standard command and
specific command like (File, Edit, View, Project, Format, Debug, Run, etc.)
The toolbar has buttons that provide shortcuts to some of the menu options
and Contains several icons that provide quick access to commonly used
features.
2
Lecture 3... Visual Basic 6.0
The main window also shows the location of the current form relative to the
upper left corner of the screen (measured in twips) and the width and length of the
current form.
2- Form1 (Form) window: contains a form named Form1, which is where the
program‘s Graphical User Interface (GUI) will be displayed as shown in Fig. (2-
5).
3- Toolbox Controls: Contains a collection of tools that are needed for project
design as shown in Fig.(2-6). To show the toolbox press View> toolbox icon. The
user can place the tool on form, and then work with the tool. To place the tool on
form: click on tool>draw tool to form > the tool appears on form or double click
on tool then the tool appears on form. Table (2-1) summarizes the toolbox
controls.
3
Lecture 3... Visual Basic 6.0
4- Properties Window: The properties window displays the properties for a form or
control as shown in Fig.(2-7). Properties are attributes such as size, position, etc.
like a form; each control type has its own set of properties. Some properties, like
width and height, such as, are common to both forms and controls, while other
properties are unique to form or control. Controls often differ in the number and
type of properties. Properties are listed either alphabetically (by selecting the
alphabetic tab) or categorically (by selecting the categorized tab). The most
important properties of the objects in general are listed in the following table. To
show the properties window press View> properties window icon. Table (2-2)
explain objective of the properties window.
Properties
Objective
name
Name Used to represent name of object in code.
Caption Name appears on object.
Back color Background color for object.
Fore color Color of text written on object.
Font Font style type and size
Visible The tool is visible or invisible.
Enable The tool enable or disable
5
Lecture 3... Visual Basic 6.0
5- Form Layout Window: The Form Layout window specifies a form‘s position on
the screen at runtime as shown in Fig.(2-8). The Form Layout window consists of
an image representing the screen and the form‘s relative position on the screen.
With the mouse pointer positioned over the form image, drag the form to a new
location.
6- Project Window: displays a list of all forms and modules making up your
application see Fig.(2-9). You can also obtain a view of the Form or Code
windows (window containing the actual Basic coding) from the Project window.
Note:
Fig.(2-10).
7- Code Editor Window:
Code Editor Window is used to write a VB code for an application. For
each form there is a separate code editor window. It is displayed when
user clicks on form or objectin form. As shown in Fig. (2-11).
7
Lecture 3... Visual Basic 6.0
Events:
Events are like electrical switches. The electrical switches are
of many types, so are the events. The form and controls support
events (generation, interaction with mouse and keyboard). The
most important events in Visual Basic are described in the
following table.
Practical part
Code:
Private Sub Form_Load()
Form1.BackColor = QBColor(12)
End Sub
Example 2-2: Design a form such that: in event click on form, when
project runs, the title of theform changed to applied science.
8
Lecture 3... Visual Basic 6.0
Exercises: