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


End Sub You might be able to un derstand this code, but without in denting, it is hard to tell which End If


Download 1.37 Mb.
Pdf ko'rish
bet172/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   168   169   170   171   172   173   174   175   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

End Sub
You might be able to un derstand this code, but without in denting, it is hard to tell
which
End If
goes with which
If
and under what cir cumstances each line will
get executed. This is much easier to un derstand when everything is indented:
Sub NestedIf()
If gradeNum > 90 Then
MsgBox ("Great job. You got an A.")
If gradeNum = 100 Then
MsgBox ("You are per 
fect.")
End If
ElseIf gradeNum > 80 Then
MsgBox ("Good work. B is a very good grade.")
ElseIf gradeNum > 70 Then
MsgBox ("Not bad. C is still pass 
ing.")
If gradeNum < 72 Then
MsgBox ("That was close. You were lucky to get a C.")
End If
Else
MsgBox ("You can do better than this.")
End If
If gradNum > 70 Then
MsgBox ("You have passed this class.")
End If
End Sub
An Ounce of Prevention 165


Each part that is in dented is now clearly part of the line be fore it. It is eas iest
to in dent and un-in dent as you go be cause as you type your code, you know what
you mean.
Hints from the VBA Editor
On a Windows computer, the VBA Ed itor of ten tries to give you helpful
suggestions. You might have no ticed that when you type a dot, sometimes a box
pops up with pos sibilities for what to type next. See Fig ure 9.3 for an example.
Figure 9.3. Auto-Complete Sug gestions from the VBA Ed itor
In this case the scrollable window gives you a list of all the things you can
type af 
ter
ActivePresentation
. You can choose from the list by dou 
-
ble-clicking on any item, or you can start typ ing. As you type, the window high -
lights the first thing in the list (in al phabetical or der) that matches what you type.
If noth ing is highlighted, you have typed something wrong. Gen erally, that list is
all that is available to type. If the list of choices has gone away, you can de lete
the line back to the dot; when you type the dot again, the list will come back.
In ad dition, in Windows the VBA Ed itor will make some sug gestions for
pa ram e ters for pro ce dures. For ex am ple, if you type

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   168   169   170   171   172   173   174   175   ...   191




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