Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


Download 1.37 Mb.
Pdf ko'rish
bet122/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   118   119   120   121   122   123   124   125   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

For
 Next Loops
Sometimes you have a specific num ber of times you want to loop. 
For
Next
loops allow you to do this and keep a count of the loop. This could be done
with a 
While
or 
Do
loop by add ing one to a
count
vari able in side the loop, but it 
can be eas ier with a 
For Next
loop.
A sim ple example of a 
For Next
loop fol lows:
For i = 1 To 10
MsgBox("Count 
ing..." & i)
Next i
This uses the variable
i
and counts from 1 to 10. That is,
i
starts out at 1, and the
loop keeps loop ing (ev erything be tween the
For
line and the 
Next
line is run)
over and over again, adding 1 to 
i
, up to and including the time that 
i
be comes
10.
Next i
says to go back to the beginning of the loop and in crease
i
. As with
all the other loops, you can put as many lines as you like between the
For
line
and the
Next
line, and all those lines will be ex ecuted over and over again.
For Next
,
Do
, and 
While
loops can get more com plicated, but these ba sic
loops should suit most of your pur poses.
Loop ing 123


In fi nite Loops
Before we leave looping, a word of warning about infinite loops: In all of
our loops, we have set stop ping con ditions; that is, we have told the loop when to
stop loop ing. What if the stop ping con dition is never met? Then you have an in -
finite loop, a loop that never stops. Here is a simple example (don’t type this):

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   118   119   120   121   122   123   124   125   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling