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

Visual Basic

Visual Basic is a high-level programming language evolved from earlier versions of BASIC. It uses a graphical interface that allows programming by dragging and dropping objects instead of text-based coding. Visual Basic is event-driven and makes use of forms, controls, modules and procedures to create the application interface and behavior.

Uploaded by

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

Visual Basic

Visual Basic is a high-level programming language evolved from earlier versions of BASIC. It uses a graphical interface that allows programming by dragging and dropping objects instead of text-based coding. Visual Basic is event-driven and makes use of forms, controls, modules and procedures to create the application interface and behavior.

Uploaded by

Cj Antonio
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Visual Basic

Introduction to Visual Basic


 VISUAL BASIC is a high level programming language evolved from
the earlier DOS version called BASIC.
 BASIC stands for Beginners' All-purpose Symbolic Instruction
Code
 The program codes in Visual Basic resemble the English language
 Different software companies produce different versions of BASIC,
such as Microsoft QBASIC, QUICKBASIC, GWBASIC, and IBM
BASICA and so on.
 VISUAL BASIC is a VISUAL and events driven Programming
Language
Divergences from the old BASIC.
BASIC VISUAL BASIC
Programming is done in a text- Programming is done in a
based environment and the graphical environment.
program is executed sequentially.
Text-based procedure to design the Design the interface by dragging
interface and resizing the objects as well as
changing their colors, just like any
windows-based programs.

 Visual Basic is event-driven because users may click on a certain object


randomly, so each object has to be programmed independently to be able
to response to those actions (events).
 Examples of events are clicking a command button, entering text into a
text box, selecting an item in a list box etc. Therefore, a VISUAL
BASIC Program is made up of many subprograms; each with its own
program code which can be executed independently and at the same time
can be linked together in one way or another.
The Visual Basic Environment
The Visual Basic Environment
The Visual Basic Environment
a- Menu Bar: It contains a standard command like: File, Edit, View,
Window, Help menus, and specific command such as: Project, Format, or
Debug menus.

b- Toolbar: it contains the most commonly used commands (button), if


clicked an action represented by that button is carried out.

c- Toolbox: it contains a collection of tools that are needed for project design.

d- form Designer: it is a window for each form to customize the designed


interface of the application. Using the form designer, the user can add
controls, graphics, and text to create the desired form appearance.

e- Properties Window: it is a List of properties settings for a selected form


or
a control. These properties are characteristics (such as size, visible, or color)
of the selected object it provides an easy way to set properties.
The Visual Basic Environment
f- Project Explorer Window: it is a list of the forms and modules for the
current projects. lt is a hierarchical tree- branch structure, where the project at
top of tree and other parts like forms ,modules) descend from this tree.

g- Form Layout Window: The Form Layout window is a small screen.


Which is used to reposition the form of the application so that it appears in
proper place when project is run.

h- 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 object in form.
The controls available for a Standard.exe project

The toolbox includes many tools and in general


they are:
1) Pointer (not control) : used to select tools
already on form
2) Picture box : Used to display images in any
of the following
formats: BMP, DIB (bitmap), ICO (icon), CUR
(cursor), WMF, (metafile), EMF (enhanced
metafile), GIF, and JPEG.
3) Label : Fixed text appears on form for
remark.
4) Textbox : For text edit .Like note pad.
5) Frame : To group tools together (container).
6) Command button : Used as a switch (such as
OK and Cancel) buttons. Code
is written in the Click event procedure of this
control
The controls available for a Standard.exe project

8) Option button : For selection as group. Many


options are placed inside
container (grouped) (a Frame control). One
control is selected from the group all
others of the group are automatically
deselected.
9) Combo box : consists of (list and arrow
when clicked a small a list appears), if user
selects item from the list, it will be displayed in
TextBox. Vertical size is fixed.
10) List box : For a list, user adds to and deletes
from this list. It takes any size.
11) Horizontal Scrollbar : Create stand-alone
Horizontal scroll bars.
12) Vertical Scrollbar : Create stand-alone
vertical scroll bars.
13) Timer : Used to control object movement.
The controls available for a Standard.exe project

14) Drive List Box : It is a special ListBox filled


automatically with names, of the files in a specified
directory. It is a list invariant.
15) Dir List Box : It is a special ListBox filled with
drives (Hard disc, Flopy, CD) in the system. It is an
invariant.
16) File List Box : It is a special ListBox filled
automatically with the names of all DirListBox. It
is a list invariant.
17) Shape : Used only to display rectangles, circles,
and ovals on the forms. Never raises any events
18) Line :Used only to display lines on the forms. It
never raises any events.
19) Image : Used instead of PictureBox because it
consumes fewer system resources.
20) Data : used for data base.
21) OLE : used for joining with another programs.
The controls available for a Standard.exe project

14) Drive List Box : It is a special ListBox filled


automatically with names, of the files in a specified
directory. It is a list invariant.
15) Dir List Box : It is a special ListBox filled with
drives (Hard disc, Flopy, CD) in the system. It is an
invariant.
16) File List Box : It is a special ListBox filled
automatically with the names of all DirListBox. It
is a list invariant.
17) Shape : Used only to display rectangles, circles,
and ovals on the forms. Never raises any events
18) Line :Used only to display lines on the forms. It
never raises any events.
19) Image : Used instead of PictureBox because it
consumes fewer system resources.
20) Data : used for data base.
21) OLE : used for joining with another programs.
Introduction to Visual Basic
list of objects
list of procedures
Displaying the output

Private Sub Form_Activate ()


A = "Tom "
B = “likes "
C = “to "
D = “eat "
E = “burgers."
Print A & B & C & D & E
End Sub

+or the & operator to join two or more texts (string).


Summation of values using textbox, label, command button

Private Sub Command1_Click()


'To add the values in TextBox1 and TextBox2
Sum = Val(Text1.Text) +Val(Text2.Text)
'To display the answer on label 1
Label1.Caption = Sum
End Sub
Operators in Visual Basic

Arithmetical Operators

Operators Description Example Result


+ Add 5+5 10
- Substract 10-5 5
/ Divide 25/5 5
\ Integer Division 20\3 6
* Multiply 5*4 20
^ Exponent (power of) 3^3 27
Mod Remainder of division 20 Mod 6 2
"George
& String concatenation "George"&" "&"Bush"
Bush"
Operators in Visual Basic

Relational Operators

Operator Exampl
Description Result
s e
> Greater than 10>8 True
< Less than 10<8 False
>= Greater than or equal to 20>=10 True
<= Less than or equal to 10<=20 True
<> Not Equal to 5<>4 True
= Equal to 5=7 False
Operators in Visual Basic

Logical Operators

Operator
Description Example
s
Compare two variables if a
AND If x AND y ThenEnd If
AND b equals
Compare two variables if a
OR If x or y Then End If
OR b equals

You might also like