macro for calculating

C

cherylhyams

Im creating a powerpoint presentation in which I want the viewer to be
able to click on different coins in order to pay for an item of
clothing. Is there a macro code that will calculate how much they have
spent according to which coin images they have clicked on.

Ideally i would like there to be some sort of sound effect to indicate
if they have paid the correct amount.

Not sure if this is possible or not?
 
D

David M. Marcovitz

This is certainly possible. The basic (without testing) code for keeping
track of the amount would be something like:

Dim total as Long 'This line is really important and comes first

Sub Nickel()
total = total + 5
End Sub

Sub Dime()
total = total + 10
End Sub

etc.

You might also have a testing function:

Sub IsItRight()
If total = 135 Then 'assumes the answer is $1.35
MsgBox "That's it!" 'replace this with code to play a sound
'which I can't remember off the top of my
'head.
End If
End Sub

Then you would have to call IsItRight either by linking it to a button,
or putting it in the procedures for all your coins, such as:

Sub Dime()
total = total + 10
IsItRight
End Sub

If you stick with the MsgBox approach, your If statement could be more
complicated by testing if the total is over or under (possibly saying
"keep going" if it is under and "too much" if it is over).

This should get you started.

--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

(e-mail address removed) wrote in @a26g2000pre.googlegroups.com:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top