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


MsgBox and then move to the next slide un der one condition, but pop up a dif ferent MsgBox


Download 1.37 Mb.
Pdf ko'rish
bet116/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   112   113   114   115   116   117   118   119   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

MsgBox
and then move to the next slide un der one
condition, but pop up a dif ferent
MsgBox
and then move to the previous slide un -
der a dif ferent condition:
If gradeNum >= 90 Then
MsgBox ("You got an A.")
ActivePresentation.SlideShowWindow.View.Next
Else
MsgBox ("You need to work harder.")
ActivePresentation.SlideShowWindow.View.Pre 
vious
End If
Because you can do sev eral things in re sponse to a yes an swer, you can do sev -
eral complicated things. The above ex ample uses two simple statements, but you 
can have as many statements as you want. Some of these state ments might be
complicated structures like loops (see the next section) and other 
If
state ments.
When you put an
If
block in side an 
If
block, it is called a nested 
If
. If the an -
swer to your question is yes, you might want to ask other questions:
Con di tion als: The
If State ment 119


If gradeNum >= 90 Then
MsgBox ("You got an A.")
If previousGradeNum >= 90 Then
MsgBox ("Good job. Two A grades in a row!")
End If
ActivePresentation.SlideShowWindow.View.Next
Else
MsgBox ("You need to work harder.")
ActivePresentation.SlideShowWindow.View.Pre 
vious
End If
Pay careful attention to the way this example is in dented. Al though you don’t
have to type it in dented in this way, it is much easier to un derstand with the in dent-
ing. You can see that the question is asked: Is 
gradeNum
greater than 90? Every-
thing be tween the first
If
and the
Else
is in dented to show that it is what to do if
the answer is yes. Part of what to do is to ask an other question. That question asks
if

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   112   113   114   115   116   117   118   119   ...   191




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