0% found this document useful (0 votes)
57 views

Lecture 1 PDF

Visual Basic is a graphical programming language derived from BASIC. It allows programmers to build graphical user interfaces by dragging and dropping prebuilt objects onto forms. The Visual Basic IDE provides an integrated environment for creating, running, and debugging Visual Basic programs. It contains various windows like the form, toolbox, properties window, and project explorer to facilitate programming. Programs are created as projects containing forms, modules, and other elements.

Uploaded by

M M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Lecture 1 PDF

Visual Basic is a graphical programming language derived from BASIC. It allows programmers to build graphical user interfaces by dragging and dropping prebuilt objects onto forms. The Visual Basic IDE provides an integrated environment for creating, running, and debugging Visual Basic programs. It contains various windows like the form, toolbox, properties window, and project explorer to facilitate programming. Programs are created as projects containing forms, modules, and other elements.

Uploaded by

M M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1-Introduction

Hundreds of high-level languages have been developed, but only a few


have achieved broad acceptance, for example (QBASIC, FORTAN and
Pascal). Visual Basic is an example of a graphical-based language. A
graphical-based language allows the user to work directly with graphics.
Visual Basic is derived from the “visual” term refers to the method used to
create the graphical user interface (GUI), Simply drag and drop prebuilt
objects into place on screen without having to learn an additional software
package. The “Basic” term refers to the BASIC (Beginners All-Purpose
Symbolic Instruction Code) language, a language used by more
programmers. Visual Basic has evolved from the original BASIC language
and now contains several hundred statements, functions, and keywords,
many of which relate directly to the windows GUI. Beginners can create
useful applications by professionals to accomplish anything that can be
accomplished using any other windows programming language.

Visual Basic is a Microsoft Windows Programming language. Visual Basic


programs are created in an Integrated Development Environmental (IDE).
The IDE allows the programmer to create, run and debug Visual Basic
programs conveniently. IDEs allows a programmer to create working
programs in a fraction of the time that it would normally take to code
programs without using IDEs.

1.1 The advantages of Visual Basic:

1- It's simple language. Things that may be difficult to program with other
language can be done in Visual Basic very easily.

2 - Because Visual Basic is so popular, There are many good resources


(Books, Web sites, News groups and more) that can help you learn the
language. You can find the answers to your programming problems much
more easily than other programming languages.

Visual Basic page 1


3 - Compare to other languages, Visual Basic have the widest variety of
tools that you can download on the internet and use in your programs.

2-Structure of a Visual Basic Application.

To run Visual Basic program select, Start> Programs > Microsoft Visual
Studio 6.0> Microsoft Visual Basic 6.0 as shown in Fig.(2-1). When Visual
Basic is loaded, the New Project dialog shown in Fig.(2-2) is displayed.

Fig.(2-1) Computer screen. Fig.(2-2) New Project dialog.

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.

2-1 Project (VBP)


Project is a program designed to user application that may be simple
(like calculator program) or complex (like word program). The project
types listed in Fig.(2-3) are the “Visual” in Visual Basic, because they
Visual Basic page 2
contain predefined features for designing Windows programs. The project
is a collection of files that makes the user program. They may consist of
form, modules, active x controls. The new project dialog contains three
tabs
• New: creating new project.
• Existing: opening an existing project.
• Recent: opening a project that has been previously loaded into the
IDE.
2-2 Elements of Integrated Development Environmental (IDE).
Figure (2-3) shows The IDE after Standard EXE is selected. The top of the
IDE window (the title bar) displays “Project1-Microsoft Visual Basic
[design]”.The environment consists of various windows when Visual Basic
is started (by default):

2-2-1 Project1-Form1 (Form):

window contains a form named Form1, which is where the program’s


Graphical User Interface (GUI) will be displayed. A GUI is the visual portion
of the program, this is where the user enters data (called inputs) to the

Visual Basic page 3


program and where the program displays its results (called outputs) .We
refer to the Form1 window simply as “the form”. Forms are the foundation
for creating the interface of an application. You can use the forms to add
windows and dialog boxes to your application. You can also use them as
container for items that are not a visible part of the application’s interface.
For example, you might have a form in your application that serves as a
container for graphics that you plan to display in other forms.

2-2-2 Toolbox Controls:

Contains a collection of tools that are needed for project design as shown
in Fig.(2-4). 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 (1) summarizes the
toolbox controls.

Table (1): Toolbox controls summary.

Visual Basic page 4


Control Description
Pointer Used to interact with controls on the
form(resize them, move them, etc.).
The pointer is not a control
PictureBox A control that display images or
print the result.
Label A control that displays uneditable
text to the user.
TextBox A control for accepting user input.
Textbox can also display text.
Frame A control for grouping other
controls.
CommandButton A control that represents a button.
The user presses or clicks to initiate
an action.
CheckBox A control clicks to initiate an action.
the user with a toggle choice
(checked or unchecked)
OptionButton Option buttons are used in groups
where only one at a time can be
true.
ListBox A control that provides a list of
items.
ComboBox A control that provides a short list of
items.
HscrollBar A horizontal scrollbar.
VscrollBar A vertical scrollbar.
Shape A control for drawing circles,
rectangles, squares or ellipse
Line A control for drawing line.
DrivelistBox A control accessing the system disk
drivers.
DirlistBox A control accessing directories on a
system
Filelistbox A control accessing file in a directory
Image A control for displaying images. The
images control does not provide as

Visual Basic page 5


many capabilities as a picturebox.
OLE A control for interacting with other
window applications.
Timer A control that performs a task at
programmer specified intervals. A
timer is not visible to the user.

2-2-3 Properties Window:

The properties window displays the properties for a form or control.


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.

Properties name Objective


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
Height Length of object
Width Width of object
Top Coordinates of top of object on screen
Left Coordinates of left of object on screen
Text Allows inputting and editing text in
object.

Visual Basic page 6


2-2-4 Project Explorer Window:

The window titled Project-Project1 is called the Project Explorer and


contains the project files. The project explorer window’s tool bar contains
three buttons, namely view code, view object and toggle folders. When
pressed, the view code button displays a window for writing Visual Basic
code. View object, when pressed, displays the form. Double-clicking form1
(form1) also displays the form. The toggle folders button toggles (i.e.,
alternately hides or shows) the forms folder. The forms folder contains a
listing of all forms in the current project. To show the Project Explorer
window press View> Project Explorer window icon.

2-2-5 Form Layout Window:


The Form Layout window specifies a form’s position on the screen at
runtime. 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.
2-2-6 Menu Bar:
Contains a standard command and specific command like (File, Edit,
View, Project, Format, Debug, Run, etc.).
2-2-7 Tool Bar:
Contains several icons that provide quick access to commonly used
features
2-3 Code Form:
standard form has one code form for code. The user can write code in this
code form (as a work sheet) in the design stage. This code will be applied
at run time. The code is written in code form and it will be edited quickly
by code editor. The codes are of two categories:

• Declaration is written before any procedure in the code.
• Statements. The user selects the required event then code statements
are written in side these event procedures.

Visual Basic page 7


2-3-1 Sub Procedures:
A Sub Procedure is a block of code that is executed in response to an
event. By breaking the code in a module into Sub procedures, it becomes
much easier to find or modify the code in your application. The syntax for a
Sub procedure is:
[Private Sub procedurename (arguments)

Statements
End Sub

2-3-2 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.

vent Action taken when It provide the


following integers
Click Single click on object.
DbClick Double click on object.
Mouse move Mouse pointer move Button ,shift ,X,Y
object.
Key press Pressing a key of the Key Ascii
key board.
DragDrop Move object to another Source, X, Y
place.

Visual Basic page 8

You might also like