Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21096

[RESOLVED] Why doesn't this code work using a timer

$
0
0
Code:

Private Sub Command1_Click()
Chill 5, "CASHREGISTER" ' 5 seconds
End Sub

 Sub Chill(seconds As Integer, SoundName As String)
Dim Counter As Integer
  seconds = seconds * 1000
  If Counter <= seconds Then
    Timer1.Enabled = True
    Counter = Counter + 1000
    sndData = LoadResData(SoundName, "SOUND")
    sndPlaySound sndData(0), SND_LOOP Or SND_ASYNC Or SND_MEMORY
  If Counter >= seconds Then
    Timer1.Enabled = False
    sndPlaySound ByVal 0, 0 'stop sound
    End If
 
  End If

Trying to get it to stop after 5 seconds
The sound is loaded from a resource file and it just keeps sounding and doesn't stop

Viewing all articles
Browse latest Browse all 21096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>