5 Control Structures
5 Control Structures
5 Control Structures
Programming
2
Control Structures
Control Structures
• Allows the programmer to alter the normal flow of
statement execution.
Syntax:
If condition Then
action(s)
End if
Using If Statement
• Use indentation.
• In the nested If statement, each If must have its own
End If statement.
• Care should be taken to make If blocks easy to
understand.
Relational Operators
MATHEMATICAL VISUAL BASIC NUMERIC MEANING
NOTATION NOTATION
= = Equal to
# <> Unequal to
< < Less than
> > Greater than
<= <= Less than or equal
>= >= Greater than or equal
Logical Operators
• The result of a logical operator is also True or False.
OPERATOR SYMBOL
AND And
OR Or
NOT <>
Assignment Statements
• The simplest statement is the assignment statement.
It consists of a variable name (var), followed by the
assignment operator (=), followed by an expression
(expr).
Example:
StartTime = Now
Explorer.Caption = “Captain marvel”
count = count + 1
num = 5
count = count + num /2
Comment Statements
• An apostrophe (‘) can be used to indicate comments;
comments are ignored by Visual Basic.