Do you find this program a little bit confusing?
Yes—something about all those IFs...
Its not just you.
Other people find this confusing.
When things are nested three deep
(an IF inside an IF inside an IF),
everyone gets a little uneasy.
Luckily QBasic has a special control structure that helps this.
The IF-ELSEIF structure looks like this:
IF condition-1 THEN branch-1 ELSEIF condition-2 THEN branch-2 ELSEIF condition-3 THEN branch-3 . . . ELSEIF condition-n THEN branch-n ELSE else-branch END IF
Here is how this structure works:
ELSEIF sections as you want.END IF (so no other branch will execute.)
You don't have to have an ELSE and its else-branch.
If you
omit them, then if no condition is true no branch at all will execute.
The ELSEIF structure is an extension
to the fundamental IF-THEN-ELSE-END IF structure.
You don't really need it, but sometimes it is very convenient.
If your program needs to choose several options from many possibilities, can this structure be used?