Visual Basic (VB) is a high level programming Code Window - This is where you type in the code
language evolved from the earlier DOS version called that VB executes.
BASIC = developed by Microsoft BAKA KASAMA SA TRUE OR FALSE TO
• A common programming error is to begin coding
BASIC stands for Beginner’s All-purpose Symbolic before analysis of the problem and design of the
Instruction Code. solution is incomplete
Developed by John Kemeny and Thomas Kurtz in The solution should consist of a logical sequence of
mid1960s. steps, called an algorithm
VB DEVELOPED IN MID 1991 • Only one option button in a group can be on at the
Windows is a Graphical User Interface (or GUI) = same time.
allow users to easily operate In the nested If statement, each If must have its own
Event-Driven Programming End If statement.
• Procedural programs - Loop control variable has an initial value.
Execution starts with the first line. Loop control variable has a Step value
Code remains idle until called upon to respond to Each For statement must end with a Next statement.
some event (button pressing, menu selection Steps in Designing a VB Application
VB Terminologies 1.Decide on the Interface for the user. (Forms &
Control - A tool used to create objects on a Visual Controls)
Basic form. 2. Determine which events the objects on the window
Objects - The name of a user interface element you should recognize.
create on a Visual Basic form by using a toolbox 3. Write the events procedures for those events.
control, eg button Naming Convention
Property - A value or characteristic held by Visual Use the Property window to change the Name
Basic object, such as Caption or ForeColor property of an object.
Event Procedure- A block of code that is executed Good Programming habit is that each name begins
when an object is manipulated in a program with a three letter prefix that identifies the type of
Program Statement - A keyword in the code that control.
does the work of the program. Common Properties
Method - A special statement that performs an action Left, Top, Width, and Height Properties - All visible
or a service for a particular object in a program. objects— forms and controls—expose these
Class - An implementation of an object type. properties, which affect the object’s position and size.
Inheritance - Objects are organized into object ForeColor and BackColor Properties - color of the
classes, which are groups of objects sharing structural text and the color of the background, respectively.
and behavioral characteristics. Font Property - Forms and those controls that can
Encapsulation - The result (or act) of hiding the display strings of characters expose the Font
implementation details (information hiding) of an object property.
from its user. Caption and Text Properties - The Caption property is
Visual Basic Integrated Development Environment a string of characters that appears inside a control)and
(IDE). that the user can’t directly modify
Main Window - This is the only element of the IDE Enabled and Visible Properties - you might want to
which is always visible. hide them or show them in a disabled state.
Toolbox Window - The toolbox is simply a library of TabStop and TabIndex Properties - If a control is able
controls which you can place on your application. Eg, to receive the input focus, it exposes the TabStop
add buttons property.
Project Window - This is simply a list of all forms and MousePointer and MouseIcon Properties - affect the
modules which make up your VB project. shape of the mouse cursor when it hovers over a
Property Window - these parameters are called control. The MouseIcon property is used to display a
properties. Some properties can be entered at design custom, user-defined mouse cursor.
time within the IDE , change font color Visual Basic Events
Form Window - They are the windows which hold the Code is a set of statements that will be executed when
various controls which make up your Application. you run a program.
Click and DblClick Events - A Click event occurs when String: Hold characters,
the user left-clicks on a control, whereas the DblClick Date: A data type used to store dates and times as
event occurs—you guessed it—when he or she real number.
double-clicks on the control using the left mouse Variant: A special data type that contain numeric,
button. string or date as well as the special values Empty and
Null.
• GotFocus and LostFocus Events - GotFocus fires
when a control receives the input focus, and User-defined: Any data type defines using the Type
LostFocus fires when the input focus leaves it and statement.
passes to another control. Variable Naming Convention
KeyPress, KeyDown, and KeyUp Events must begin with a letter
Form is a window style screen that Visual Basic can contain letters, numeric digits, and underscore
program displays. The Form is where everything Variable Declaration
happens To declare a variable, use Dim statement
Command Button - Creates a button the user can Dim variable-name As data-type
choose to carry out a command. Concatenation - Two string can be combined with the
Label control is use to display text that a user can’t concatenation operation. & sign.
edit directly Using Text Boxes for Input/Output
TextBox Control - Text boxes are used to display The contents of a text box are always a string.
information entered at design time, by a user at Arithmetic Operators
run-time, or assigned within code. The displayed text MOD - Used to divide to numbers an return only the
may be edited. remainder (Integer Remainder)
ListBox Control - Provides a list of items to the user Relational Operators - The execution of the block If is
Combo Box Control - A combo box is best thought of controlled by a Boolean Expression.
as a text box with a help list attached. = Equal to
Two most useful types of combo box are: - Dropdown <> Unequal to
combo box - Simple combo box < Less than
CheckBox Control - Provides a yes/no option to the > Greater than
user <= Less than or equal
RadioButton Control - Used to give the user a single >= Greater than or equal
choice from several options. Assignment Statements - The simplest statement is
Timer Control - The timer control, is invisible during the assignment statement.
run time. The event triggered each time Comment Statements - An apostrophe (‘) can be used
Timer1.Interval milliseconds elapses is called to indicate comments; comments are ignored by
Timer1.Timer(). Visual Basic.
Variables and Constants Control Structures - Allows the programmer to alter
Data is constant when it cannot be changed after a the normal flow of statement execution.
program is compiled. Types of Control structures: 1. Loop 2. Decision
Types of constants: Numeric and String If Statement = An action is taken if the condition is
String Constants - A group of alphanumeric data true, otherwise the control goes to the next statement
consisting of any type of symbols. Looping - the process of repeating a series of
Byte: A data type used to hold positive integer statements as many times as needed. also called
numbers ranging from 0 to 255. iteration.
• Integer - –32,768 to +32,767. Basic Components of Loops
Long - Larger range Loop control variable: A variable used to determine
Single Precision: Real numbers. Accuracy of 7 digits. whether a loop will be executed
Can be identified by !. Loop body: The statement (s) that are executed each
Double Precision: Accuracy of 16 digits. time a loop repeats
Boolean - TRUE OR FALSE Do While … Loop - The loop body is executed as long
Currency: This type is used in money-related as the condition is True.
calculations and for fixed-point calculations.
Counter-controlled Loops - Is useful when the
programmer knows how many times the loop should
be executed
Do Until ……. Loop -• Is executed until the condition
becomes True
Comparing While… and Until Loops
The Do While … Loop executes while the condition is
true
The Do Until ... Loop executes until the condition is
true
For … Next Loop - Is used to create a counting loop.
Rules for Using For ... Next loop -
The initial, terminal, and step values cannot be
modified in the loop body.
If you are not sure, use Do While….. Loop.