With
statement is just like the
With
in
GetStarted
, re ferring to the
TextRange
where the clues are stored. The code:
.Paragraphs(1).Text = "Eye Color: " & userClue & Chr$(13)
changes the first paragraph (the one that in cludes the eye color clue) to whatever
the user typed. The
If
state ment then checks to see if what was typed was
“blue”:
If userClue = "blue" Then
If it is, it changes the color of the fourth word (which would be the word “blue”)
to blue:
.Paragraphs(1).Words(4).Font.Color.RGB = vbBlue
The
ElseIf
part checks to see if the user typed green and changes the color of
the text to green.
Guess
uses an
InputBox
to ask for the user’s guess. The part that checks
for the correct an swer is a se ries of
If
,
ElseIf
,
ElseIf
,
ElseIf
, and
Else
state ments. The
If
section is for the right answer. It shows the picture of the ap-
ple pie (be cause DeeDee wanted the ap ple to make pie):
ActivePresentation.Slides(5).Shapes(7).Vis
i
ble = True
It shows a
MsgBox
tell ing the user that the answer is correct:
MsgBox ("You are right, " & userName & _
". Would you like a piece of pie?")
And when the user clicks OK on the
MsgBox
, it jumps back to the beginning:
ActivePresentation.SlideShowWindow.View.GotoSlide (1)
The two
ElseIf
clauses each bring up a
MsgBox
with specific feedback
about what was wrong, and the
Else
clause (if the user typed anything be sides
“DeeDee,” “BeeBee,” or “CeeCee”) brings up a
MsgBox
that gives the ge neric
feedback “Try again.”
To create your own mystery, simply change text on the mystery and clue
slides, change the text in the VBA code that re fers spe cifically to eye color and hair
color (in case your clues are about something else), change the text on the eye color
and hair color but tons, and change the
Do'stlaringiz bilan baham: |