You are on page 1of 14

INTRODUCTION TO

VISUAL BASIC

by Santosh K Deval, PGT (CS)


Object Oriented Programming
• Object is an identifiable entity with some
characteristics and behaviour
• A Class represents a group of objects that
share common properties and relationships
• OOP Paradigm – Decide which classes
and objects are needed; provide a full set
of operations for each class
Event Driven Programming
• An Event refers to occurrence of a user-
action
MouseDown, DblClick, KeyPress,
KeyDown, KeyUp, …..
• EDP is based upon the occurrence of
events and the occurrence of
action/reactions in response to the events
that have occurred.
VISUAL BASIC
• Early 1990 by Microsoft
• Successor of BASIC
• Supports EDP
• Quick development
• Quick error detection/correction
• Windows Development language
• ActiveX support
• Start -> Programs -> MS Visual Studio -> MS Visual Basic

• Project is a collection of several different types of files that


make up a program
• Application is the final program made up of one or more
projects
• IDE Components
 Title Bar
 Menu Bar
 Tool Bar
 Tool Box
 Form Designer
 Project Explorer Window
 Form Layout Window
 Code Editor Window
OBJECT
• Name
• Properties
• Method – Causes an object to do
something
• Events – Activities that happen
• Event Procedures – Code that is executed
when an event occurs
DATA TYPES
• Boolean T/F
• Byte 0-255 + integers
• Currency 8 bytes
• Date/Time
• Double 8 bytes
• Integer 2 bytes –32768 to 32767
• Long 4 bytes
• Object Controls and Form
• Single 4 bytes
• String
• Variant Default data type
Variables
• Decalring
Dim <var> [As <Datatype>]
Dim rollno As Integer
Dim chk
• Implicit and Explicit variable declaration
Explicit – Option explicit in CODE
• Variable Scope
 Private
 Module
 Public
Operators
• Math
+, -, *, /, \, Mod, ^
• Concatenation
&, +
• Comparison
=, <>, >, >=, <, <=
• Logical
AND, OR, NOT, XOR
Control Statements
• If <cond> Then
<stmt>
EndIf
• If <cond> Then
<stmt-1>
Else
<stmt-2>
EndIf
• If <cond-1> Then
<stmt-1>
Else If (cond-2> Then
<stmt-2>
Else
<stmt-3>
EndIf
Control Statement
• Select Case <expr>
Case <val-1>
<stmt-1>
Case <val-2>
<stmt-2>……
Case Else
<stmt-n>
End Select
• Case “A”
• Case Is >= 85
• Case 0 to 49
Loop statement
• For <var> = <start> to <end> [step <n>]
…..
Next
• While <expr>
<stmt>
Wend
• Do While <expr>
<stmt>
Loop
• Do
<stmt>
While <expr>
VB Practicals
• How to start
• Examples – Screen design oriented
• Examples – Fundamental programming
HAVE A NICE TIME with
VB Programming

You might also like