Help with VB, Buttons, and running totals...

  • Thread starter Thread starter goken
  • Start date Start date
G

goken

Hey guys :) if you've been looking around, you've probably seen m
Jeopardy thread... well, it's going pretty well, got the popup for th
question, and different actions taken if it is answered correctly o
incorrectly... but our snag now is we are trying to find a way to kee
a runnig total displayed on the slides at all times...

Here's what we've come up with so far:

We put a Custom Button on the slide master...

In the macro manager, at the top we have

Dim score As Integer

to set "score" as a changable integer....

Then on each slide we define the button as:

ActivePresentation.SlideMaster.Shapes(8).TextFrame.TextRange.Text = "
& score

What we're trying to figure out is how to make score keep a runnin
total (I know its possible with excel worksheets) and automaticall
update in the button when a question is answered correctly o
incorrectly...

Thanks for all the help!!
 
Glad to see you are making progress! Here is a sample of what I do. I have
a variable called "intScore1" (I actually keep three scores, one for each
Team). I have a text box on the SCORE slide (actually under the picture of
the player inside the podium) that maintains the value of "intScore1". The
two lines of code that I use on the respective question/answer slide that
adds a value to the existing score is:

' assuming this is a 100 point question, this line adds 100 to the existing
score
intScore1 = intScore1 + 100
' this line takes that value and assigns it the text object "Score1" on
Slide 3
ActivePresentation.Slides(3).Shapes("Score1").TextFrame.TextRange.Text =
intScore1

I also do other things like return to the Score Slide and hide the dollar
amount for that question on the Board Slide, but this will get you started
(hopefully)!

Good Luck!

Bill Foley
www.pttinc.com
 
ok i understand what you're saying, and we try that... but it does no
keep the score running...

what happens is, we have it

dim Score as Integer

and up towards the top we have

ActivePresentation.SlideMaster.Shapes(8).TextFrame.TextRange.Text = "
& score

just so that we can get the button on our slidemaster to displa
score...

and then in another macro (unforunately i dont know any better, so
made MULTIPLE subs, one for each question) when the user answers th
question correctly it goes to correct

(if userAnswer = 24 then goto Correct Else goto Wrong) thats what w
have....

we have that working, but what happens when we go to correct is this:
Correct:

score = score + 100
SlideShowWindows(1).View.GotoSlide 8

End

and so when it goes to slide 8, it shows it as being 100, but when w
go to answer another question, say a 200 point question (score = scor
+ 200) it just displays 200 rather than adding both the previous 10
and the newly added 200...


so what i'm saying is, it constantly resets itself to 0...

is there any way to get a universal "score" that all subs can add to
because i think that it is acting like Score is 0 since its dim'd as a
integer up top and yet in each sub it doesnt have a value listed...


any help, if its not too complicated (i doubt it is, you guys are pur
genius peoples here it seems) or too horribly worded, i'd show you th
exact code if i had it with me but i think i left it in my car...


P.S. i'm the one working with goken on this project.
 
Two things that may help:

Str(integer) = a text conversion of the number in integer.

DoEvents = Allows the computer to catch up on things like screen updating.



B
===============
Please spend a few minutes checking out www.pptfaq.com This link will
answer most of our questions, before you think to ask them.

Change org to com to defuse anti-spam, ant-virus, anti-nuisance
misdirection.
 
You mention that you have lots of subroutines.

Do you have Option Explicit on the first line of the module? I'd do that
right off the bat. That can help prevent all manner of subtle mistakes.

Your problem might be that each sub is, in effect, maintaining its own copy
of a variable called Score. If so, it'll always be set to zero at the
beginning of the sub and go out of scope (aka disappear) when the sub's
done.


--
Posted to news://msnews.microsoft.com
Steve Rindsberg, PPT MVP
PowerPoint FAQ - www.pptfaq.com
PPTools - www.pptools.com
===============================
 
As Steve says you are losing the scope on the variable. Instead of
Sub something()
Dim score as integer
etc
end sub

try this

Public Score as integer


Sub something()
score = score + 100
etc
end sub

This will keep the value of the Score alive through multiple sub
routines.

Brian Reilly, PowerPoint MVP
 
thank you Steve and B, steve i think that is exactly the problem, but
not sure... and B i'm not to certain about what either of those
commands do but i will look into them don't worry :)

if either of them help or even if all do, thanks... i'll try to write
them into the code asap which will probably be next tuesday depending
on if goken got anywhere earlier today or not with it
 
We had a short class yesterday so I didn't really get muc
accomplished... Hog can you e-mail me the presentation since i didn
get a disk? so i can play with it a bit here... (e-mail address removed)
 
Back
Top