value in text box

M

morag

I don't know much about vba, Iv'e been trying to figure out how to do stuff
through using other people's code.
so, this is what i'd like to do:
I'm creating a powerpoint learning game which teaches hebrew. there is a
slide for each letter. each slide has 4 correct answers and 4 wrong answers.
all along the presentation there are correct score and wrong score shapes
with their value visible. (I added them in the slide master). after 4 correct
answers were clicked, the presentation advances to the next slide.
my problems:
1. when I run the slide show the score value does not begin with 0 (although
macro begin was activated)
2. it does not advance to the next slide.
I would really appreciate if anybody can look at my code and tell me what
i'm doing wrong. Thanks in advance!

Const ls = 3 (ls stands for last slide)
Dim current_correct As Integer (current_correct counts how many correct
clicks were made on current slide in order to advance after 4)
Dim correctbox As Shape (this shows number of correct clicks all along
presentation)
Dim incorrectbox As Shape ((this shows number of correct clicks all along
presentation)
Dim sn As Integer
Sub Begin()

ActivePresentation.SlideMaster.Shapes("correctbox").TextFrame.TextRange.Text
= 0

ActivePresentation.SlideMaster.Shapes("incorrectbox").TextFrame.TextRange.Text = 0
current_correct = 0
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub Rightanswer()
ActivePresentation.SlideMaster.Shapes("correctbox").TextFrame.TextRange.Text
=
ActivePresentation.SlideMaster.Shapes("correctbox").TextFrame.TextRange.Text
+ 1
check_done
End Sub

Sub check_done()
current_correct = current_correct + 1
If current_correct = 4 Then
current_correct = 0
advance
End If
End Sub
Sub Wronganswer()

activePresentation.SlideMaster.Shapes("incorrectbox").TextFrame.TextRange.Text
=
ActivePresentation.SlideMaster.Shapes("incorrectbox").TextFrame.TextRange.Text + 1
End Sub

Sub advance()
sn = SlideShowWindow.View.Slide.SlideIndex
If sn <> ls Then
ActivePresentation.SlideShowWindow.View.Next
End If
End Sub
 
D

David M. Marcovitz

Your code works perfectly for me with one small exception. In advance(),
you need sn = ActivePresentation.SlideShwoWindow.View.Slide.SlideIndex

Once I change that, everything works as expected. That will take care of
the advancing to the next slide issue. As for the correct score not
showing up in the text box, it won't show up on the first slide because
you will need to have a button that runs Begin on the first slide. Until
that button is pressed, the score boxes will be incorrect.

--David
 
M

morag

David M. Marcovitz said:
Your code works perfectly for me with one small exception. In advance(),
you need sn = ActivePresentation.SlideShwoWindow.View.Slide.SlideIndex

Once I change that, everything works as expected. That will take care of
the advancing to the next slide issue. As for the correct score not
showing up in the text box, it won't show up on the first slide because
you will need to have a button that runs Begin on the first slide. Until
that button is pressed, the score boxes will be incorrect.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/



Thanks alot for your response.
I'm still stuck. the first slide is an empty slide which has a button to run
sub begin. it advances to the second slide where the score is all wrong. the
score gets corrected and updated only once a button in the second slide is
clicked and sub rightanswer or sub wronganswer are called.
the presentation does not advance to the next slide after 4 correct answers
even after fixing the code.
I'm using ppt 2007 with vista. any clue?
Thanks again! (espically since getting this far comes from reading your very
helpful posts on this forum)
 
D

David M. Marcovitz

I'm not sure what to tell you. The only change I made to your code was
listed below. Everything else worked perfectly. One thing that comes to
mind is that you are using the old model for the master slide. I was
testing in 2003, and you are working in 2007. Perhaps, 2007 can't handle
the old model of masters as well. Look here for information about how to
program the new model of masters:

http://skp.mvps.org/designs.htm

--David
 

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