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

Visual Basic 6.0

Visual Basic is an event-driven programming language and integrated development environment. It allows connecting programming code to graphical user interfaces. Visual Basic was developed by Microsoft and first released in 1991. It uses variables, constants, operators, and keywords to write programming code. Common constructs in Visual Basic include if/else statements, loops, arrays, functions, and connecting to databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Visual Basic 6.0

Visual Basic is an event-driven programming language and integrated development environment. It allows connecting programming code to graphical user interfaces. Visual Basic was developed by Microsoft and first released in 1991. It uses variables, constants, operators, and keywords to write programming code. Common constructs in Visual Basic include if/else statements, loops, arrays, functions, and connecting to databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

INTRODUCTION TO VISUAL BASIC

• Visual Basic is a third-generation event-driven programming language and integrated


development environment.
- Event-driven Programming is a programming paradigm (type) in which the flow of the
program is determined by events such as user actions (mouse clicks, key presses),
sensor outputs, or messages from other programs/threads.
- Integrated Development Environment (IDE) is an interface/environment that
programmers use to develop their applications.
• Connecting the programming language (BASIC) to the GUI.
- Graphical User Interface (GUI) is an interface through which a User interacts with
applications by making use of graphics.
• Visual Basic was integrated as a part of Microsoft’s Visual Studio.
• Invented by Alan Cooper in the year 1991.
• Stable release: 6.0/1998

2
Title Bar
Menu Bar

Tool Bar

Project Explorer
Toolbox

View Code
Window

Form Designer

Properties Window

View Object
Window

Immediate Form Layout


Window Window

VISUAL BASIC IDE COMPONENTS

3
INTRODUCTION TO VISUAL BASIC CONTROLS

4
INTRODUCTION
Variables
Data name, used to store a data value which can be changed during program
execution.
Constants
Constants refer to fixed values that do not change during the execution of a program.
Operators
An operator is a symbol that tells the computer to perform certain mathematical or
logical manipulations.

6
RULES FOR DECLARING VARIABLES
Variable name must begin with an alphabet.
Variable names cannot exceed 255 characters.
Variables should not contain a period(.)
Variable names should be unique in the declared context.

7
KEYWORDS
Reserved words.
Cannot be used as names for the program variables or other user-defined program
elements.
Loop LSet Me Mod

New Next Not Nothing

Null On Option Optional

Or ParamArray Preserve Private

Public RaiseEvent ReDim Rem

Resume RSet Select Set

Shared Single Static …..

8
OPERATORS
Type Operators
Arithmetic Operators +, -, *, /, mod, ^
Comparison Operators =, <>, >, <, >=, <=
Logical/Relational Operators AND, OR, NOT, XOR
Concatenation Operators + (effective on strings), &

9
EXAMPLE

10
SCOPE OF THE VARIABLES
Description
• Variables declared using “Dim” keyword
at script level are available to all the
procedures within the same script.
Dim
• Variables declared using “Dim” keyword
at a Procedure level are available only
within the same procedure.
Variables declared using "Public" keyword
Public are available to all the procedures across all
the associated scripts.
Variables that are declared as "Private" have
Private scope only within that script in which they
are declared.

11
SIMPLE If STATEMENT
An if statement consists of a Boolean expression followed by one or more statements.
If the Boolean expression evaluates to true, then the block of code inside the if
statement will be executed. If the Boolean expression evaluates to false, then the first
set of code after the end of the if statement will be executed.

13
EXAMPLE

14
If…Else STATEMENT
An if statement can be followed by an optional else statement, which executes when
the Boolean expression is false.
If the Boolean expression evaluates to true, then the if block will be executed,
otherwise, the else block will be executed.

15
EXAMPLE

16
NESTED If OR If…Else STATEMENTS
Use of one if or if…else statement inside another if or if…else statement(s).

17
EXAMPLE

18
If…ElseIf LADDER STATEMENT
The if…elseif statement is used to execute one code from multiple conditions.

19
EXAMPLE

20
Select Case STATEMENT
A select case statement allows a variable to be tested for equality against a list of
values known as case.

21
EXAMPLE

22
Option Button

23
Check Box

24
WHAT IS LOOP?
A loop in VBScript is used to execute a block of code or a part of the program for
several times.
It saves code.

26
TYPES OF LOOPS

LOOPS

do do…loop do for...next
while…wend
while…loop while until…loop loop

27
Do While…Loop
The do while statements will be executed as long as condition is True.

28
EXAMPLE

29
While…Wend
Tests the condition before executing the loop body.

30
EXAMPLE

31
Do…Loop While
Iterates the code until the condition is false.
Condition is given after the code. So at least once the code is executed whether the
condition is true or false.

32
EXAMPLE

33
Do Until…Loop
The do..until statements will be executed as long as condition is False.

34
EXAMPLE

35
For...Next LOOP
A for loop is a repetition control structure that allows a developer to efficiently write a
loop that needs to execute a specific number of times.

36
EXAMPLE

37
WHAT IS AN ARRAY?
Collection of elements (data) in a single variable.
Linear Data Structure
- A data structure (data organization and storage format that enables efficient
access and modification) is said to be linear if the elements form a sequence.

39
EXAMPLE (1D ARRAY)

40
EXAMPLE (2D ARRAY)

41
FUNCTION VS SUB PROCEDURE
Function Sub Procedure
A single block of code written to A single block of code written to
perform a specific task that may perform a specific task that does
or may not return a value. not return a value.
Functions are always enclosed Sub procedures are always
within Function and End Function enclosed within Sub and End
statements. Sub statements.

43
EXAMPLE (FUNCTION)

44
EXAMPLE (PROCEDURE)

45
STEPS (VB 6.0 – MS ACCESS CONNECTION)

47
EXAMPLE

48
EXAMPLE

50
EXAMPLE

52
EXAMPLE

54
EXAMPLE

56
EXAMPLE

58
EXAMPLE

60
REFERENCES
Courtesy of FreeTutes - Visual Basic Tutorials. URL:
http://www.freetutes.com/learnvb6
Courtesy of TutorialsPoint – VBScript Tutorial. URL:
http://www.tutorialspoint.com/vbscript
Courtesy of JavaTPoint – C Programming Language Tutorial. URL:
http://www.javatpoint.com/c-programming-language-tutorial

61

You might also like