Do Un
til count >= 3
an
swer = InputBox("What do you like to eat?")
count = count + 1
Loop
In the first example, the loop will run at least once and ask the ques tion: How
many planets are in the solar system?
After running the loop once, it will check to
see if
an
swer
is 9. If it is, it will stop. If it is n’t,
it will loop un til the answer is 9.
In the second ex ample, the loop will run at least once and ask the ques tion:
How many planets are in the solar system? After running the loop once, it will
check to see whether
an
swer
is not 9. It
will keep loop ing while the answer is
not 9. Note, this works ex actly the same as the first ex ample,
but some times it is
easier to ask a pos itive question than a neg ative question, particularly if the ques -
tion
has many parts with
And
and
Or
.
In the third and fourth ex amples the condition will be checked be fore the
loop runs. In the third ex ample,
the loop will only run if
count
is less than 3, and
it will keep loop ing
while
count
is less than 3. In the fourth ex ample,
the loop
will stop run ning if
count
is greater than or equal to 3, and it will keep loop ing
un til
count
is greater than or equal to 3. Like the first two ex amples, these ex -
amples have ex actly the same re sults, but some times it
is eas ier to ask a positive
question, and sometimes it is easier to ask a negative question.
Do'stlaringiz bilan baham: