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


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

Ti 
tle:="Input Name")
If userName = "" Then
done = False
Else
done = True
End If
Wend
End Sub
In this procedure, we use the variable
done
to determine whether we are fin ished
loop ing. The
If
block could have all been in cluded in the 
While
state ment, elim i-
nating the need for
done
. This would have made for short VBA code, but it would
have been very dif ficult to un derstand, par ticularly if the stop ping con dition was
more and more complicated. Setting up an 
If
block allows you to check as many
conditions as you like and set
done
based on those con ditions. Then, the only
ques tion for
While
is: Are we done or not? If we are not done, keep loop ing.
Do
Loops
Do
loops are sim ilar to 
While
loops. They al low you to specify either a
While
con dition (keep go ing while something is
True
) or an 
Un 
til
con di tion
(keep go ing un til something is
True
). They also let you specify the con dition
(ask the stopping question) at the beginning or the end. If the condition is at the
beginning, the loop might never run (not even once). If the con dition is at the
end, the loop will al ways run at least once. Here are some simple examples:
Do
an 
swer = InputBox("How many plan 
ets are in the so 
lar sys 
tem?")
Loop Un 
til an 
swer = "9"
Do
an 
swer = InputBox("How many plan 
ets are in the so 
lar sys 

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   116   117   118   119   120   121   122   123   ...   191




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