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

Introduction to Visual Basic 6

Visual Basic 6.0 is a programming language designed for creating professional applications with a graphical user interface, making coding easier and faster. It features an Integrated Development Environment (IDE) that provides various tools for application development, including a toolbox for controls and a project explorer for managing project components. The document also covers variables, data types, and procedures, highlighting the advantages of visual programming and the structure of coding in Visual Basic.

Uploaded by

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

Introduction to Visual Basic 6

Visual Basic 6.0 is a programming language designed for creating professional applications with a graphical user interface, making coding easier and faster. It features an Integrated Development Environment (IDE) that provides various tools for application development, including a toolbox for controls and a project explorer for managing project components. The document also covers variables, data types, and procedures, highlighting the advantages of visual programming and the structure of coding in Visual Basic.

Uploaded by

Sayandip Mondal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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 processors and minimum of 16 M.B. of RAM and also
250 MB of hard disk to install complete enterprise edition.

Advantage of Visual Programing

Visual Programming enables


(i) Visual development of graphical user interface which are easy to use and easy to learn
(ii) A programmer need not write code to display the required component.
For example, the visual programming environment displays a list of available components.
The programmer picks up the required component from this list to display it.
(iii) The components can be moved re-sized and even deleted if so required.
(iv) There is no restriction on the number of controls that can be placed on the form.
(v) The programmer can create the user interface visually he can align, move or size the
component as required without having to resort to writing code.
(vi) The interface component provided by the visual programming environment has code
some built into them.
For example, a button knows when it has been clicked upon. In the case of conventional
programming tools, the programmer has to write code to determine the component that has
been clicked and then execute the appropriate code.

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
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 an interface.
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

Pointer Picture
Label Textbox

Frame Command Button


Option Button
Checkbox
List box
Combobox
VScrollBar
HScrollBar
DriveListBox
Timer
FileListBox
DirListBox
Shape Line
Image Data

OLE
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 List box display a list of items from which a user can select one.
 Combo Box contains a textbox and List box. This allows the user to select an item
from Dropdown List box, 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 or 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.
 Picture box displays icons/bmp/jpg and metafiles. It displays text or acts as a visual
container for other controls.
 Command Button 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 displays 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 expose the various
characteristics of selected objects.
Form Layout
The form layout window uses 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 is 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 * 10 45 for negative values.
1.401298 * 10-45 to 3.402823 * 10 38 for positive values.
Double -1.79 * 10 308 to -4.94 * 10 -324 for negative values
4.94 * 10 -324 to 1.79 * 10 308 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
Data Type Conversion
Visual Basic functions either to convert a string into an integer or vice versa and many more
conversion functions. A complete listing of all the conversion functions offered by visual
basic is elucidated below.

Conversion To Function
Boolean Cbool
Byte Cbyte
Currency Ccur
Date Cdate
Decimals Cdec
Double Cdbl
Integer Cint
Long Clng
Single Cn=sng
String Cstr
Variant Cvar
Error CVErr

Procedure:
Visual basic programs can be broken into smaller logical components called
procedures. Procedures are useful for condensing repeated operations such as the frequently
used calculations, text and controls manipulation etc. The benefits of using procedures in
programming are:
 It is easier to debug a program with procedures, which breaks a program into discrete
logical limits.
 Procedures used in one program can act as building block for other programs with
slight modification.
A procedure can be sub, function or property procedure
Sub Procedure
A sub procedure can be placed in standard, class and form modules. Each time the
procedure is called, the statement between Sub and End Sub are executed.
Syntax
[private | public ] [ static] Sub Procedure_Name [ (arg_list)]
[Statements]
End Sub
Argument list is separated by commas. Each argument acts like a variable in the
procedure. There are two type of sub procedures namely general procedures and event
procedures.
Event Procedures
An event procedure is procedure block that contains the control’s actual name, an
underscore ( _ ), and the event name
Syntax
Private sub Form1_Load( )
Statement block
End sub
This is event for form1. Execute when load form.
General Procedures
A general procedure is declare when several event procedure perform the same action.
It is good programming practice to write common statements in separate procedure and then
call them in the event procedure
Function Procedures
Function are like sub procedures, except they return a value to calling procedure.
They are especially useful for taking one or more pieces of data, called arguments and
performing some tasks with them. Then function return value that indicate result of the task.
e.g.
The following function procedure calculates area of circle of given radius.
Function Area(a as double) as double
Area = 3.14 * a^2
End Function

You might also like