After we ask the question about the student typ ing noth ing, we ask one
more ques tion. So first,
we check to see if
userName
is noth ing. If it is n’t, we
ask if
userName
is “Em ily.” If
userName
isn’t noth ing, and it is n’t Em ily, then
we
look at what co mes af ter
Else
. If
userName
is “Emily,” we have two things
to do: put up a message telling
Em ily to do her homework, and set
done
to
False
. Be cause
done
is
False
(just like it would be if
the stu dent typed noth -
ing), we’ll ask for the name again.
This could be expanded to ask as many ques tions as you want by add ing
more
ElseIf
questions. Each one could check for a different name (or an un ac-
cept able an swer, like pro fan ity) and re spond ap pro pri ately. Note that
ElseIf
does not have a space between “Else” and “If” while
End If
does
have a space
between “End” and “If.”
Using the exact same structure, we can change this from ask ing
for a stu -
dent’s name to asking for the an swer to a question. The main structure of the
VBA looks like this:
Do'stlaringiz bilan baham: