Form Timer issue in Access Game

J

Jeff Conrad

Hi,

Using Access 97 here.

I finished making a game in Access, but there is just one residual issue I
have a question about. I can live with this problem, but I'm wondering if
there is a work-around.

As the game is in progress a "clock" on the form displays the elapsed time
like a stop watch. The game is a matching game. If you select two un-matched
tiles you see the value in the text box for just a spilt second so hopefully
you remember where it is.

In order to accomplish this I had to code the second box like so:

' No match so wait just a spilt second to enable
' the user to see the two values
For Counter = 1 To 2000000
' Set a small counter loop
If Counter = 100000 Then
' Pause so we can see it
DoEvents
End If
Next Counter

I had to add in the DoEvents line because no matter HOW big of a number I
put in to the Counter you were never able to see the second box! Not good.
Adding in the DoEvents line makes it work perfect, but there is one side
effect: the stopwatch timer on the form pauses for just a spilt second. Now
I *can* live with this, but is there any way to have the best of both
worlds: keep the stopwatch going AND be able to see the text box for just a
bit? Probably not, huh?

Thanks,
Jeff Conrad
Bend, Oregon
 
K

Kelvin

Howabout instead of using a timer after the second box is revealed, using
the OnTimer event to check if the text box is showing then increment some
global variable. At some point, in a later OnTimer event, check the value
of this variable then blank out the text boxes.

Kelvin
 
J

Jeff Conrad

Hi Kelvin,

Thanks for the help.
Forgive my stupidity, but I'm a little confused by your response.
After the second text box is revealed I don't use the Timer Event at all.
(That is still running in the background)
I basically tell Access to count to a really high number in a loop.
Was that what you are suggesting?
I even tried to define it as a private variable, but the same result.
If I don't put in the DoEvents line, the second text box is never revealed.
If I leave it in, the stopwatch counter on the form pauses just for a spilt
second.

I'm pretty sure I'm just going to have to live with it.
Thanks,
Jeff Conrad
Bend, Oregon
 
K

Kelvin

No. I was suggesting that instead of your timer using the OnTimer event set
to say 250 ms. Have this event run a procedure that will check if both text
boxes have been reveal. If yes then increment a variable that has been set
to 0. If both are not revealed do nothing. Also check to see if this
variable is lets say 5, if so clear both text boxes. When both text boxes
are revealed, this code will set the variable to 1 then do nothing else. On
the next event, it becomes 2, then 3, then 4, and finally 5 (delay of
approximately 1-1.25 seconds). Now that this variable is 5, the second if
statement will cause both text boxes to get covered back up. My terminology
for what you are doing with the text boxes might be wrong, but you get my
idea. If both boxes have been picked, start this counter. On each OnTimer
event, increment this number. When the counter hits the desired number
reset both text boxes. You won't get an exact time like using your loop,
but it would be close enough that people wouldn't notice. Also, it would
produce a similar time on any machine. With your loop faster machines would
loop quicker and result in a shorter delay than you intended. Slow machines
would take longer.

Kelvin
 
J

Jeff Conrad

Humm......
I'll have to play with this.

Thanks, Kelvin
Jeff Conrad
Bend, Oregon
 

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