PDA

View Full Version : value of buttons



baz
03-20-2010, 02:39 AM
Hi,
This is my first post, and first question...hope you can help. I'm trying to create a self register PPt for younger children. It generates a random number to 10, then displays that amount of objects -say apples. I want to be able to have the children respond by clicking a but for that value -so, having 10 buttons each numbered 1 to 10. I could do it with a Inputbox, but would prefer to have some kind of action button choice. I'm new to vba, am really enjoying knocking up little activities for my class, but have really hit a block with this. Can it be done?

Thanks in advance for any help you can throw my way.

Baz

John Wilson
03-20-2010, 06:17 AM
Have ten action buttons or shapes (NOT command buttons from the control toolbox) each with a different number as text.
Make all of the shapes run this macro on click.

Sub Clickme(oshp as shape)
Msgbox “You clicked “ & oshp.TextFrame.TextRange
End Sub

baz
03-20-2010, 10:22 AM
Is that John, as in pptalchemy and pptheaven? If so once again...thanks John. It's becoming a bit of a habit. If not, then thanks John...if you see what I mean. Have just ran the code, and nothing seems to be happening, it could be me. What I want it to do is, when the correct button is clicked (ie the same number as objects displayed) then a message of `good job' or whatever appears in a textframe. Or, a `try again' appears if the incorrect button is clicked.

Does the code above need to be altered in some way to do this?

Thanks again

baz

John Wilson
03-21-2010, 02:39 AM
Yes that's the same me!

The code needs to be set as an action for each button. It cannot be run normally but ONLY by pressing the button in show mode.

You would need to alter the code a little to give a success message.

eg if there were Ivalue apples

Public Ivalue As Integer ' = how many apples
Sub ClickMe(oshp As Shape)
If Val(oshp.TextFrame.TextRange) = Ivalue Then
MsgBox "Well done"
Else
MsgBox "Sorry that's not correct"
End If
End Sub

baz
03-21-2010, 03:41 AM
Yes, it is becoming a bit of a habit...Once again, thanks John, it works perfectly. I really do appreciate your help. Like I say, my ideas (what I want to do) are a bit in fornt of where I am (my scripting ability), but am trying. Thanks alot

Baz

John Wilson
03-22-2010, 02:26 AM
"my ideas (what I want to do) are a bit in fornt of where I am"

That's a good place to be if you want to progress!