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


Download 1.37 Mb.
Pdf ko'rish
bet48/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   44   45   46   47   48   49   50   51   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Dim userName As
, you’ll see all the types of things that 
userName
can contain. There are about 300 of them, but there are just a few that you will
care about now. Common types you will use are:
Boolean
True or False val ues
In te ger
Any in teger from –32,768 to 32,767
Long
Any in teger from –2,147,483,648 to 2,147,483,647
Shape
Any PowerPoint shape (such as those things that can be drawn
with the Draw tools)
Sin gle
Non-integers (i.e., numbers with something af ter the decimal
point, such as 3.14 and 98.6)
String
Any text up to 65,536 characters long
Ob ject
Any ob ject
Now, we are ready to put it all to gether with a 
Dim
statement and two pro -
ce dures:
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
The first procedure could be associated with a but ton on the first slide, and
the second pro cedure could be associated with a but ton on a later slide. The re-
sult would be that when the first button was pressed, the student would be asked
to “Type your name.” If the stu dent types “Ada,” when the second but ton is
pressed, a message would pop up on the screen saying, “You are do ing well,
Ada.” The
&
(am per sand) char ac ter used in the
MsgBox
procedure is for con cat-
enation of strings; i.e., the two strings “You are do ing well,” and whatever is
stored in the variable
userName
(in this case “Ada”) are joined to gether to
make one string, “You are do ing well, Ada,” which is dis played in the box on the
screen.
Of course this is a simple ex ample, but it is re ally easy to turn it into a mul ti-
ple-choice quiz with feedback that uses the student’s name. Fig ure 5.3 shows the
VBA script and slides for a short quiz. The arrows show which but ton should be
connected to which pro cedure. The Next but tons and Quit button do not use
54 Let’s Get Scripting


VBA; they use traditional hyperlinks (see Chapter 2) for Next Slide and End
Show. If you have forgotten how to tie your but tons to a pro cedure, look back in
Chapter 4.

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   44   45   46   47   48   49   50   51   ...   191




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