if and else Statements are used when we need to check if certain condition is met or not, if condition is met then we follow the if condition block , if condition is not met then we follow the else condition block.
an there can be multiple if statements, but its if statement should have and end if statement, all the else statements are optional.
if statement
sub checkif()
dim a as integer
dim b as integer
a =7
b = 8
if a > b then
msgbox " a is greater than b"
else
msgbox " b is greater than a"
end if
end sub()
in example give above we have two variable a and b for both datatype is integers, both variable have value a have value 7 and b have value 8.
in if condition we are checking condition if value of a is greater then b or not, if the condition is true then if block will be executed and msgbox will show that a is greater than b, if the condition is False then ELSE block will be executed and msgbox will show that b is greater than a.
an there can be multiple if statements, but its if statement should have and end if statement, all the else statements are optional.
if statement
sub checkif()
dim a as integer
dim b as integer
a =7
b = 8
if a > b then
msgbox " a is greater than b"
else
msgbox " b is greater than a"
end if
end sub()
in example give above we have two variable a and b for both datatype is integers, both variable have value a have value 7 and b have value 8.
in if condition we are checking condition if value of a is greater then b or not, if the condition is true then if block will be executed and msgbox will show that a is greater than b, if the condition is False then ELSE block will be executed and msgbox will show that b is greater than a.
0 Comments