Académique Documents
Professionnel Documents
Culture Documents
i
i
© 2 e program prints t is sequence of numbers:
1
1.5
2
2.5
Ú i=1 5
Ú j=1 5
i + j
j
I
©In Visual Basic, you can use an Exit For statement to
exit a For...Next loop before t e loop as finis ed
executing.
©
s ould repeat.
© As an alternative to a Ú
statements until a
certain condition in t e loop is true.
© A Standard Do Loop::
|
|
|
!
i=0
i < 25
'block of statements to be executed
"value is :: "; i
i=i+1
!
© NO2E ::
2 is code brings up an interesting fact about Do Loops:
if t e condition at t e top of t e loop Is not 2rue
w en t e Do statement is first evaluated, Visual Basic
never executes t e Do loop.
© If you want t e loop to always run at least once in a
program, put t e conditional test at t e bottom of t e
loop.
© If a loop test never evaluates to False , t e Loop will execute endlessly, and
your program will no longer respond to input
© Do loops are relentless, so it is very important t at you design test conditions
carefully.
© If a loop test never evaluates to False , t e Loop will execute endlessly, and
your program will no longer respond to input
© So far, t e Do loops you ave seen use t e W ile keyword to
execute statements as long as t e
© In Visual Basic, you can also use t e Until keyword in Do loops to
cycle 6
6@
© 2o test a condition, you can use t e ÿ
" t e
6
^ ÿ #
© A loop t at uses t e Until keyword is very similar to a loop t at uses
t e W ile keyword.
Label1.Caption = 2ime
& $
$%%
© In t is example of a digital clock, setting t e timer
'''(m
update t e clock time every 1000 milliseconds
(once per second).
xOOD DAY !!