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


Download 1.37 Mb.
Pdf ko'rish
bet178/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   174   175   176   177   178   179   180   181   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Ex er cises to Try
Ä
The following code is not indented. What will happen if Ella
types 5? What will hap pen if anyone else types 5? What will hap-
pen if Ella types 10? What will happen if anyone else types 10?
Try to figure it out without run ning the code. Type it into the
VBA Ed itor and indent it prop erly; see if you come up with a dif-
ferent answer now that it is in dented. Run the code to see if you
got the right an swer.
 Sub HowDoYouFeel()
 Dim score As In 
teger
 Dim userName As String
 userName = InputBox("What is your name?")
score = InputBox("On a scale of 1 to 10, how do you feel?")
 If score > 5 Then
 If score > 7 Then
 If score > 9 Then
 If userName = "Ella" Then
 If score > 10 Then
 MsgBox ("That’s amaz 
ing")
 Else
 MsgBox ("That’s per 
fect")
 End If
 ElseIf score < 6 Then
 MsgBox ("That’s mid 
dling")
 Else
 MsgBox ("You’re per 
fect.")
 End If
 ElseIf score = 5 Then
 MsgBox ("Are you mid 
dling?")
 Else
 MsgBox ("Are you above av 
erage?")
 End If
 ElseIf score = 5 Then
 MsgBox ("Right in the mid 
dle")
 Else
 MsgBox ("That’s good")
 End If
 Else
 MsgBox ("Not too good.")
 End If
 End Sub
Ex er cises to Try 171


Ä
The following is the en tire con tents of a module. It con tains four
bugs. Try to find all four by typ ing the code into the VBA Ed itor
and us ing the debugging and error prevention methods in this
chap ter.

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   174   175   176   177   178   179   180   181   ...   191




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