You are on page 1of 3

*** Visual Basic Lecture ***

Historical Overview of BASIC


- BASIC – Beginner’s All-Purpose Symbolic Instructions Code
- The BASIC programming language was created by Professor John George Kemeny in the 60’s to help introduce students
to computer programming.
- The language was designed to be interpreted, rather than compiled.

History of Visual BASIC


- A product of Microsoft Corporation.
- First released in 1991

IDE (Integrated Development Environment)


 Allows the programmers to create, run, and debug programs conveniently.
 Allows a programmers to create working programs in a function of a time that it would normally take to code programs
without using IDEs

Versions of Visual Basic


1. Learning Edition- provides fundamental programming capabilities.
2. Professional Edition – provides much richer set of programming capabilities
3. Enterprise Edition – Is used for developing large-scale computing systems.

Object Oriented Programming for VB


 Control – a tool used to create object on a visual basic form. It is used to create user interface elements, such as command,
buttons, image, boxes and list boxes.
 Objects – the name of a user interface element you create on a visual basic form by using a tool box control.
 Property – a value or characteristic held by visual basic object such as caption or fore color.
 Event Procedure – a block of code that is executed when an object is manipulated in a program.
 Method – a special statement that performs an action on a device for a particular object in a program.
 Program Statement – a keyword in the code that does the work of the program.
 Inheritance – objects are organized into object classes which are groups using sharing structured and behavioral
characteristics.
 Encapsulation – The result of hiding the implementation details of an object from its user.
 Abstraction – the benefit of being able to ignore the inner object details of an object in order to focus on the object needed to
use.
 Polymorphism – creates objects that perform the same object but which performs some of these functions in different ways.

The Visual Basic Environment


The Basic Parts (VB Components)
1. Title bar
2. Control box (Min,Max,Close Button)
3. Menu Bar – contains group of related capabilities which the user may select appropriate choices.
4. Standard Toolbar – is compromised of pictures called icons that represent commands.
5. Control Toolbox / Toolbox – contains controls used to customize forms.
6. Project Explorer - contains three buttons.
- View Code – display a window for writing visual basic code.
- View Project – when pressed, displays the form.
- Toggle folders – toggles the forms folder
7. Properties Window – display form attributes or properties.
8. Form Lay-out – enables the user to specify the forms position on the screen when the program is executed.
9. Form Window- the primary programming unit in visual basic where in you place controls.
10. Immediate Window – use for immediate output, use for testing the short statement code.

Steps in Creating Visual Basic Application


A. Create the user interface
B. Setting the properties
 Naming object in program
 Naming object in convention
C. Writing code
D. Saving program
E. Running program
F. Making (set-up) project

To Run the VB Program: Press F5

Mr. Jeffre P. Gabriel, <jpg1623™> Page 1 of 3


*** Visual Basic Lecture ***

Naming Objects Conventions

Object Prefix
ADO Data Control ado
Check Box chk
Combo Box cbo
Command Button cmd
Data dat
Data Grid dtg
Directory List Box dir
Drive List Box drv
File List Box fil
Form frm
Frame fra
Horizontal Scrollbar hsb
Image img
Label lbl
Line lin
List Box lst
OLE ole
Option Button opt
Picture Box pic
Shape shp
Text box txt
Timer tmr
Vertical Scrollbar vsb

Variables- a temporary storage or hidden of information in a program.


Rules in Naming Variables
 Begin each variable name w/ letter. Variable names must be fewer than 256 characters long & cannot contain
periods.
 Make you’re Variable names Descriptive by combining one or more words when it makes sense to do so.
 Use combination of uppercase and lowercase characters and numbers. An occupied convention is to capitalize the
first letter of each word in variable.
 Don’t use Visual Basic Keywords, objects or properties as variables names.
 Begin each variable name with a two or more three characters abbreviation corresponding to the type of data that is
stoned in the variable (optional) declaring variables.

Global - creates a variable that will be available to all parts of a program


- Used only within modules
Ex.
Global Global-ctr as integer
Global Global-DArr () as integer
Global Global-SArr (1 to 50) as integer

Dim - used designated a variable’s type


- Can be used within any portion of a program.
Ex.
dim Intvar as integer
dim Fixedstr as string * to
dim Dynstr as string
dim ArrayInt (1 to 10) as integer
dim TwoDimArr (1 to 10, 1 to 20) as integer

Static - use designated to pressure the contents of variables or an array

Public - use to declare variables & constants w/c will be available w/ in the module where they were declared
Private - restricts a class (depending on the location) to constants, variables & procedures.

Mr. Jeffre P. Gabriel, <jpg1623™> Page 2 of 3


*** Visual Basic Lecture ***

Visual Basic Data Types


Data Types describe the information that a variable stores

Data Types Bytes Range Type Declaration char.


Boolean 2 True or False
Byte 1 0 to 255
Currency 8 -922337203685477.5808 AT sign, @
-922337203685477
Date 8 1 January 100- 31 December 9999
Double 8 -1-79E 308 to- 4. 94E Pond sign, #
-324 (negative)
-1.79E308 to 4.94E
-324 (positive)
Integer 2 -32768 to 32767
Long 4 -2147483648 to 2147483647 Percent sign, % Ampersand, &
Object 4 Any Object Type
Single 4 -3.40E38 to -1.40E Exclamation point, !
-45 (negative)
3.40E38 to 1.40E
-45(positive)
String 10+ 0 to ~ 2,000,000,000 chan Dollar sign $
Variant 16 Any value within the ranges listed below

Ex. Expression
Cash @ = cash @ - fee @
Circle Area # = PI # * r # ^ 2
Total % = total % + grade %
Print diskspace &
Colorname $ = “yellow”

Arithmetic Operators
Operation Operator
Addition +
Subtraction -
Multiplication *
Division(float) /
Division(Integer) \
Exponentiation ^
Negation _
Modules Mod

Precedence of Operator
Operators Order
() 1
^ 2
-(Negation) 3
* Or / 4
\ 5
Mod 6
+ or - 7

Storing Data in Variable


An assignments statement is way of storing data in variable
 Format of an assignment statement that assign a value to an object property
[ form ].Object.Property = value
 Format of an assignment statement that assign in a variable

variableName = value

Mr. Jeffre P. Gabriel, <jpg1623™> Page 3 of 3

You might also like