Variables
Variables
REPRESNTED WITH -“ ”
1. EXPLICIT
WITHOUT DECLARATION
”
BY THE NAME & DATA TYPE. ADDING NAME (SUFFIX TO VARIABLE)
STRING $
INTEGER %
LONG &
SINGLE !
DOUBLE #
CURRENCY @
VISUAL BASIC ARITHMETIC OPERATIONS
OPERATOR OPERATIONS
+ ADDITION
- SUBTRACTION
* MULTIPLICATION
/ DIVISION
% MODULUS
^ EXPONENTIAL
VISUAL BASIC RELATIONAL OPERATIONS
OPERATOR OPERATIONS
> GREATER THAN
7 DAYS STRING
0 1 2 6
If (n>0) then
Print “n is positive”
End if
1.IF………THEN…….ELSE
STATEMENT
• In this statement if the condition is true then the statement before the word else will
be executed .
• If the condition is false ,the statement after the wor else will be executed until it
finds the word end if
• Syntax:-
If(condition) then
Statement 1
Else statement 2
Endif
EXAMPLE
We can use the Else keyword to create a simple branch.
If the expression inside the brackets following
the If keyword evaluates to false,
the statement
following the Else keyword is automatically executed.
If (n>0) then
Print “n is positive”
Else
Print “n is negative”
Endif
Select statement
The Select statement is a selection control flow statement.
It allows the value of a variable or expression to control the flow of program
execution via a multi way branch.
It creates multiple branches in a simpler way
than using the combination of If, Else If statements.
We have a variable or an expression.
The Select keyword is used to test a value from
the variable or the expression against a list of values.
The list of values is presented with the Case keyword.
If the values match, the statement following the Case is executed.
There is an optional Case Else statement.
It is executed if no other match is found.
Dim grade As String
Case "A"
print "High Distinction"
Case "B"
print "first class“
Case "C"
print "second class“
Case “D"
print "pass“
Case Else
print "Fail"
End Select