Dim userName As String
Sub YourName()
userName = InputBox(prompt:="Type your name", _
Ti
tle:="Input Name")
End Sub
Sub DoingWell()
MsgBox("You are do
ing well, " & userName)
End Sub
You could as sociate a but ton with each of these pro cedures, so the us ers
click on the first button to type their names and (probably at some later point)
click on the other but ton to be told how well they are do ing. What if we want to
praise them right away, to encourage them right after they have typed a name?
We could write another procedure that calls the two pro cedures above:
YourNameWithPraise()__YourName__DoingWell_End_Sub_No_but_tons_have_to_be_as_sociated_with_YourName_or_DoingWell'>Sub YourNameWithPraise()
YourName
DoingWell
End Sub
No but tons have to be as sociated with
YourName
or
DoingWell
.
Cre ate a but-
ton and as sociate it with
YourNameWithPraise
, and that is all you need. The
but ton will ac ti vate
YourNameWithPraise
. When
YourNameWithPraise
starts to ex ecute it will see the first line:
YourName
.
That sig nals it to run the
YourName
pro cedure. When it finishes the
YourName
pro cedure, it will run
DoingWell
. Your module will look like Figure 5.5.
Fig ure 5.5. YourNameWithPraise Calls YourName and DoingWell
60 Let’s Get
Scripting
Con clu sion
You now have learned a few ba sic scripts to in teract with your stu dents.
You can get in put and use it in feedback, ei ther to in clude a student’s name in the
feedback or to judge a short-answer question. In the
next chap ter you will ex-
pand your bag of VBA tricks, in cluding ways to manipulate your PowerPoint
slides, such as moving from slide to slide and hiding ob jects on your slides.
Do'stlaringiz bilan baham: