Some question on the .Interval property of a Timer
Hi all,
I have a question here...does anyone really has an idea of the Timer's .Interval property?
What i mean is, .Interval = 500 is equal to how many micro,milli-seconds of the real time? :confused:
Thanks guys :WAVE:
Justin
[271 byte] By [
ootnitsuj] at [2007-11-11 8:48:57]

# 3 Re: Some question on the .Interval property of a Timer
Hi Phil,
I have just checked...The maximum for .Interval is only 64,767, which is around 1 min.
Now i have a prob here, if my music is more than 1 min, do i have an alternative to repeat the song? Coz right now i am using a timer to repeat the song...
Thanks
# 5 Re: Some question on the .Interval property of a Timer
Option Explicit
Private Declare Function playa Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_FLAG = &H1 Or &H2
'Timer interval is set as such so that the music will be played again after the music has ended @ 4min11sec later
'The music is also played when the application is first executed
Private Sub Form_Load()
Timer1.Interval = 64767
Call PlayWav("D:\Music\A1\Here We Come\08 Like a Rose.wav")
End Sub
'The music is play when Play button is clicked
Private Sub cmdPlay_Click()
Call PlayWav("D:\Music\A1\Here We Come\08 Like a Rose.wav")
End Sub
'The music stopped when the Stop button is clicked
Private Sub cmdStop_Click()
Call PlayWav(vbNullString)
End Sub
'The timer will start the music again after the music has stopped
Private Sub Timer1_Timer()
Call PlayWav("D:\Music\A1\Here We Come\08 Like a Rose.wav")
End Sub
'The music stopped when the application is closed
Private Sub Form_Unload(Cancel As Integer)
Call PlayWav(vbNullString)
Unload Me
End
End Sub
'Procedure to play the music
Private Sub PlayWav(sFile As String)
If Dir(sFile$) <> "" Then Call playa(sFile, SND_FLAG)
End Sub
This is a simple program that will play a song (.wav) when the app starts running, and the user has the option to stop the music and play the music.
It has 2 command buttons - Play and Stop, and 1 timer to repeat the song (song of duration of 4min 11sec).
Thanks for your help pclement.
# 6 Re: Some question on the .Interval property of a Timer
You can use the SND_LOOP flag with SND_ASYNC to play the sound file continuously and asynchronously. When you want to stop the sound from playing you just call sndPlaySound again with a null value sound name (file) parameter. See the following for details:
How To Play a Waveform (.WAV) Sound File in Visual Basic (http://support.microsoft.com/kb/q86281/)
# 7 Re: Some question on the .Interval property of a Timer
Hi pclement,
I have tried your recommendation and it works great...
but one thing is, whenever i stop the music or when the program is closed, it will produce this aweful beep(or ding..whatever!!) sound...i think its giving an indication that it has detected a null file..
Can i remove this aweful sound??