Solved

Sound and labels rotates no longer works correctly

Posted on 2014-01-24
6
211 Views
Last Modified: 2014-01-27
I have an 80 number keno game and on a win 2 labels rotate up to the amount won
at the same time a sound plays at the same time and the sound stops when the labels stop rotating.
This has worked in the past, but now the labels do not rotate until the sound has stopped.
 i cannot determine why. the code:

Dim miCnt As Long' form level variable


Sub AddRunWinning(AmountWon As Currency) 
mEndNum = AmountWon

        miCnt = 1
        Timer1.Interval = 60
        Timer1.Enabled = True
        'Play the ADDINGWINNINGS.wav file frome the resource file
        sndData = LoadResData("ADDINGWINNINGS", "SOUND")
        sndPlaySound sndData(0), SND_LOOP Or SND_ASYNC Or SND_MEMORY
  

End Sub

Private Sub Timer1_Timer() 
Dim lblcreditcurrency As Currency
lblcreditcurrency = GetPriceByBetMode(mBetMode)
  Debug.Print "miCnt " & miCnt
        If miCnt <= mCreditsWon Then
            lblWinThisRun.Caption = lblWinThisRun.Caption + 1
          If mCreditMode = 1 Then' currency
            lblCredit.Caption = CCur(lblCredit.Caption) + lblcreditcurrency
            lblCredit.Caption = Format(lblCredit.Caption, "currency")
            miCnt = miCnt + 1
          Else
            lblCredit.Caption = Val(lblCredit.Caption) + 1
            miCnt = miCnt + 1
          End If
          
        Else
             Timer1.Enabled = False
            'Stop the Sound
            sndPlaySound ByVal 0, 0
        End If
End Sub


Private Function GetPriceByBetMode(ByVal betMode As Integer) As Double
    Select Case betMode '1cent, 2cents etc
        Case 0
           GetPriceByBetMode = 0.01
        Case 1
           GetPriceByBetMode = 0.02
        Case 2
           GetPriceByBetMode = 0.05
        Case 3
           GetPriceByBetMode = 0.1
        Case 4
           GetPriceByBetMode = 0.25
    End Select
End Function

Open in new window


What is wrong ?
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
  • 3
  • 3
6 Comments
 
LVL 30

Expert Comment

by:gowflow
ID: 39808313
Couple of questions
I tried to get your code to work but missing following:

What is the interval of the timer ?
I am missing a sub sndPlaySound

and what is the initial value of lblcredit and lblwinthisrun

as if I get both to be 0 the routine stops when they are both 1 How should it work ?
gowflow
0
 

Author Comment

by:isnoend2001
ID: 39808638
Private Declare Function PlaySoundData Lib "winmm.dll" Alias "PlaySoundA" (lpData As Any, ByVal hModule As Long, ByVal dwflags As Long) As Long
Const SND_ASYNC = &H1 ' /* play synchronously (default) */
Const SND_NODEFAULT = &H2 '/* silence (!default) if sound not found */
Const SND_MEMORY = &H4 '/* pszSound points to a memory file */
Const SND_LOOP = &H8 '/* loop the sound until next sndPlaySound */

What is the interval of the timer ? Line 8

and what is the initial value of lblcredit and lblwinthisrun
lblcredit, could be any value
lblwinthisrun;could be any value
lblwinthisrun;always starts at 0 and is increased by the amount of the win
lblcredit,could be any value, but is increased by the same win amount
The problem is the labels and sound should both run at the same time.
I start the timer before the sound, but the timer does not fire until after the sound plays.
I confirmed this by putting a brake at lblcreditcurrency = GetPriceByBetMode(mBetMode) in the timer, but it does not hit the break point until the sound stops
0
 

Author Comment

by:isnoend2001
ID: 39808673
I have found a work around by putting label rotation and sound both in the timer
Private Sub Timer2_Timer()
    If iCnt <= mEndNum Then
        lblWinThisRun.Caption = iCnt
        LblCredit.Caption = LblCredit.Caption + 1

If mbStop <> True Then ' form variable
      sndData = LoadResData("ADDINGWINNINGS", "SOUND") 'load from resource file
    sndPlaySound sndData(0), SND_LOOP Or SND_ASYNC Or SND_MEMORY
    mbStop = True
 End If
    iCnt = iCnt + 1
    Else
        iCnt = 1
        Timer2.Enabled = False
        'Stop the Sound
        sndPlaySound ByVal 0, 0
    End If
    End Sub
Tried all kinds of corrections to code that worked previously
Deleted Timer1 and put a new timer and named itTimer1
Put a new Timer2 and coded that
Break point on the timer to be sure it was firing after the sound stopped.
All to no avail
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Accepted Solution

by:
gowflow earned 500 total points
ID: 39810418
ok I just made-up a new project and zipped it.
Once you open it rename the file
MSSCCPRJ.txt
to
MSSCCPRJ.SCC
as it is not accepted by EE to upload.

run the project and tell me if this is what your looking for.
Regards/gowflow
Label-Sound.zip
0
 

Author Closing Comment

by:isnoend2001
ID: 39810826
Thanks
i am giving you the points for your efforts. I have working example the way it is written in my question. The question remains why does the timer not start when the sound does.
don't know what programs open .SCC files my vb6 files are .vbp
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39811292
you may delete the file with .txt and simply run the vbp project. did you try the project I uploaded ?
gowflow
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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