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


Download 1.37 Mb.
Pdf ko'rish
bet62/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   58   59   60   61   62   63   64   65   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

MsgBox
re turns
vbYes
. We might want to do something based on the
button pressed. For example:
'Ask if you like choc 
olate. Give an ap 
propriate re 
sponse.
Sub Choc 

late()
Dim chocolateAnswer
chocolateAnswer = MsgBox("Do you like choc 
olate?", vbYesNo)
If chocolateAnswer = vbYes Then 'The user likes choc 
olate.
MsgBox ("I like choc 
olate, too.")
Else 'The user does not like choc 
olate.
MsgBox ("Va 
nilla is a good choice.")
End If
End Sub
Here is an ex ample for a commonly used feature: a quit button. Sometimes
users ac cidentally choose quit (by clicking on a but ton that calls a pro cedure
with
ActivePresentation.SlideShowWindow.View.Exit
). To prevent
quitting your presentation by accident, you might want to ask if the user re ally
wants to quit. As sociate the following pro cedure with your quit but ton:
The Se crets of the
MsgBox 67


'Ask if you are sure you want to quit. If the an 
swer is Yes,
'exit the pre 
sentation. If the an 
swer is No, go to the next slide.
Sub QuitOK()
're 
sult is a vari 
able to keep track of which but 
ton is clicked.
Dim re 
sult
'MsgBox re 
turns (will set the vari 
able re 
sult to) vbYes if the
'Yes but 
ton is clicked and vbNo if the No but 
ton is clicked.
re 
sult = MsgBox("Are you sure you want to quit", vbYesNo)

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   58   59   60   61   62   63   64   65   ...   191




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