Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8

Notes For Visual Basic 6.

0
1
Sunil S. Trivedi
Introduction to Visual Basic 6.0
Visual basic is an ideal programming language for developing sophisticated professional
applications for Microsoft windows. It makes use of graphical user interface for creating robust and
powerful applications. Coding in GUI environment is easy and quicker as compare to traditional, linear
programming languages.

Visual Basic was developed from BASIC programming language. It required at least Microsoft
windows 95/NT 3.51, 486 processor and minimum of 16 M.B. of RAM and also 250 MB of hard disk to
install complete enterprise edition.

Starting Visual Basic 6.0


Visual Basic is initiated by using the Program option -> Microsoft Visual Studio and Microsoft
Visual Basic 6.0 from it. Then it opens into a screen as shown below (fig 1.1)
Fig .1.1

The integrated Development Environment

One of the most significant changes in visual basic 6.0 is the integrated Development Environment (IDE).
IDE is the term commonly used in the programming world to describe the interface and environment that
we use to create our applications. It is called integrated because we can access virtually all of the
development tools that we need from one screen called aninter face.

The visual basic IDE is made up of a number of components


• Menu Bar
• Tool Bar
• Project Explorer
• Properties Window
• Form layout Window
• Toolbox
• Form Designer
• Object Browser

Menu Bar:
This is bar display the commands that are required to build an application. The
main menu items have sub menu items that can be chosen when needed.

Tool Bar
The toolbar in the menu bar provide quick access to the commonly used
commands.

Toolbox
The toolbox contains a set of controls that are used to place on form at design
time thereby creating the user interface area. Additional controls can be included
in the toolbox by using the Components menu item of the Project menu. A
toolbox is represented in fig 1.2

The pointer provides a way to move and resize the control and forms.
• Label display a text that the user cannot modify or interact with.
• Frame control serves as a visual and functional container for control.
• Checkbox display a True/False or yes/no option.
• Textbox is a control used to display message and enter text.
• The Listbox display a list of items from which a user can select one.
• ComboBox contains a textbox and Listbox. This allows the user to select an
item from Dropdown
Listbox, or to type in a selection in the textbox.
• HScrollBar and VScrollBar controls allow the user to select a value within the
specified range of
value.
• Timer control executes the timer events at specified intervals of time.
• Dirlistbox allows the user to select the directories and paths, which are
displayed
• Shape control use to draw shape on form.
• Image control is used to display icons, bitmaps, metafiles etc

OLE control is used to link or embed an object, display and manipulate data from
other windows
based applications.
• Picturebox displays icons/bmp/jpg and metafiles. It displays text or acts as a
visual container for
other controls.
• CommandButton control which is a part of an option group allows the user to
select only one option even if it display multiple choices.
• The FileListBox display a set of files from which user can select the desired
one.
• The DriveListBox display the valid disk drives and allows the user to select one
of them.
• Line control to draw a line on form.
• Data control enables the user to connect to an existing database and display
information from it.

Project Explorer

Docked on the right side of the screen, just under the toolbar, is the project
Explorer window. It display objects of your project like forms, classes and
modules. All the object that make up the application are packed in a project.

Properties Window

The properties window is docked under the project explorer window. The
properties windows exposes the various characteristics of selected objects.

Form Layout

The form layout window use to place the form starting position after you runs it.

Variables, Data Types and Modules

Variable are used for storing values temporarily. Declaring a variable tells Visual
basic to reserve
space in memory. It is not must that a variable should be declared before using
it.
A defined naming strategy has to be followed while naming a variable.

1. A variable name must begin with alphabet letter and should not exceed 255
characters.
2. It must be unique within the same scope.
3. It should not contain any special character like %,&, #, @ or $

Syntax
Dim variable [as type]
For e.g
Dim str as string
Dim I as integer

Scope of variables
A variable is scoped to a procedure-level(local) or module-level depending on
how it is declared. A variable is declared in general declaration section of a Form,
and hence is available to all the procedures. Local variable are recognized only in
the procedure in which they declared. They can be declaring with dim and static
keyword.

Local Variable:
Local variable is one that is declared inside a procedure. This variable is only
available to the code inside the procedure and can be declared using dim
statement as given below
Dim I as integer

Static Variables
Static variables are not reinitialized each time visual basic invokes a procedure
and thus retains or
preserves value even when a procedure ends.
e.g.
Static in as integer

Module Level Variables


Module level variables are available to all the procedure in the module. They are
declared using
Public or private keyword.
e.g.
public nk as integer
private st as string
declaring a variable with public keyword makes it available throughout the
application even for the other modules. A variable can have same name with
different scope.

Data Type:
By default Visual Basic variables are of variant data types. The variant data type
can store numeric, date/time or string data. When a variable is declared, a data
is supplied for it that determines the kind of data they can store.
A list of visual basic data types are given below :

Type Name Values Range


Byte 0 to 255
Boolean True or False
Integer -32,768 to 32,767
Long -2,147,483,648 to 2,147,483,647
Single -3.402823 * 103 to -1.401298 * 1045 for
negative values.
1.401298 * 10-45 to 3.402823 * 1038 for
positive values.
Double -1.79 * 1030 8 to -4.94 * 10-32 4 for
negative values
4.94 * 10-32 4 to 1.79 * 1030 8 for positive
values
Date January 1, 100 to December 31,9999

String 0 to approximately 2 billion characters


Currency -922,337,203,685,477.5808 to
922,337,203,685,477.5807

You might also like