Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Ongoing vb 6 timer problem

Posted on 2014-01-27
8
Medium Priority
?
250 Views
Last Modified: 2014-01-30
I had a previous qustion about a timer not working correctly http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28347565.html#a39810418
 and found a fix by adding both the sound and label
rotation into the timer. my fix has found another problem where the timer is called from within a loop.
The program has an auto-play feature where 20 numbers are produced randomilly to an 80 number msflexgrid.
with each loop 20 numbers are randomilly produced and the results are added up if a win
It works correctly if no win, but the win is where the problem arrises
The problem is the timer only fires one time and returns to the loop
example:
 mEndNum = 4
the labes should increment 4 times, but they only do one time and return to the loop
if label lblCredit.Caption = $4.00 and mCurrencyWon = .25 then
$4.25 it stops here and returns to the loop
$4.50
$4.75
$5.00 should stop here

Private Sub Timer1_Timer()
'Dim Counter As Integer
Dim lblcreditcurrency As Currency

   If mbStartSound <> True Then
   sndData = LoadResData("ADDINGWINNINGS", "SOUND")
        sndPlaySound sndData(0), SND_LOOP Or SND_ASYNC Or SND_MEMORY
   End If         
        If miCnt <= mEndNum Then
            lblWinThisRun.Caption = lblWinThisRun.Caption + 1
          If mCreditMode = 1 Then
'          lblcreditcurrency = GetPriceByBetMode(mBetMode)
            lblCredit.Caption = CCur(lblCredit.Caption) + mCurrencyWon 'checked out
            lblCredit.Caption = Format(lblCredit.Caption, "currency")
           
            miCnt = miCnt + 1
            
          Else
            lblCredit.Caption = Val(lblCredit.Caption) + 1
            miCnt = miCnt + 1
          End If
          mbStartSound = True
        Else
            'Counter = 1
            Timer1.Enabled = False
            'Stop the Sound
            sndPlaySound ByVal 0, 0
            mbStartSound = False
        End If

Open in new window

0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 39814000
If you put a breakpoint on line 9 is miCnt <= mEndNum? If not then line 25 will turn the timer off.
0
 

Author Closing Comment

by:isnoend2001
ID: 39815048
Thanks MartinLiss

Got it to work by replacing (if) with a do loop
'If miCnt <= mEndNum Then

   Do While bFinished = False
    do sound and rotate labels
miCnt= miCnt + 1

 If miCnt > mEndNum Then          
            bFinished = True
            DoEvents
           End If
    Loop
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39815744
You're welcome.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:isnoend2001
ID: 39821780
hi MartinLiss
Thought I had the loop timer corrected, but no
Did a little test with just a form and timer

With a loop doing 12 runs
with each run the label rotates from 0 to 20
the timer returns after only 1 label rotation
and does not do any of the remaing loops
Is there a problem with a timer in a loop not finishing the loop before returning ?
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39821795
Can you zip up and attach your test project?
0
 

Author Comment

by:isnoend2001
ID: 39822159
This for the 80 number keno game. the loop is for the auto play and the 12 free bonus games
where the user does not have to repeatedly click the start button.
Everything works good until i put the timer label rotation into a loop
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question