Visual Basic - Conditional statement: if then end if, if then else end if
By conditions we can control our program. thanks conditional statement we can control program running in two directions. if the condition is satisfied to continue running the program in a first direction, if not as the second direction. under the directions of the programme I think either statement or block of statements.if then end if, if then else end if
Description
if condition then
statements1
end if
if condition then
statements1
else
statements2
end if
Input
- condition - Logical value The condition can be any expression
- statements1 - statements
- statements2 - statements
Examples
Visual Basic .NET
Conditional statement the possible of use:if i > 10 then
i =10
i = i - 1
i=i+1
end if
if i < 10 then
i = 10
else
i=1
end if
Visual Basic .NET
Other pieces of example codes:while i<20 i= i+2 if i=16 then continue while end if x=x+1 end while
do until i = 0 if i=10 then exit do else i=i-1 end if loop
do i=i+1 if i=5 then exit do end if loop while i <10
if x >= 12 then while y >= 0 y=y-1 end while end if
if x = 5 then y=y-1 end if
if y<5 then y = y/ 3.14 ' y = 1.234 end if
Conditional statement in another programming language:
Differences to: