If you are still chasing this I came up with something that seems to work. I did it in VB6 simply because I have VB6. I doubt for this there is much difference in the code. I am not a programmer type, far from it but occasionally I have to wite a little code for data acquisition and mess with Visual Basic.
Here is what I came up with:
Code: Select all
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Private Const SND_SYNC = &H0
Private Sub Command1_Click()
Form1.WindowState = 1 'Minimize form
Timer1.Enabled = True
Call sndPlaySound("F:\Windows\Media\tada.wav", SND_SYNC) 'Start with the sound file to verify it
End Sub
Private Sub Command2_Click()
End 'End the program
End Sub
Private Sub Timer1_Timer()
Text1.Text = Time 'Show time in hh:mm:ss
Text2.Text = Format(Time, "Nn") 'Show only the Minuits
Text3.Text = Format(Time, "ss") 'Show only the Seconds
If Text2.Text = 0 And Text3.Text = 0 Then 'When Min and Sec equal zero on the hour
Option1 = True
Else: Option1 = False
End If
If Option1 = True Then
Call sndPlaySound("F:\Windows\Media\tada.wav", SND_ASYNC) 'Play the sound
End If
End Sub
The Declaration is Private because if it were Public it would need to be in a seperate module.
Command1 Click event does a few things, it minimizes the Windows form, Starts Timer1 and it calls the wave file to play as a test at start.
I used 3 text boxes which really aren't needed but they show what is going on. Text1 is formatted to display the current system time, Text2 shows only the min and Text3 shows only the seconds.
On the hour the min and seconds will be 00:00 so I shoved an Option button in there as Option1. Option1 will only be true when the min and sec equal 00:00. That True state is only 1 second.
When Option1 equal True we call the wave file to play. By the time the file has completed a play Option1 is False. Since we have Private Const SND_SYNC = &H0 the file will play to completion.
Command2 will simply end the program.
You may want to try using the option button and set its properties accordingly so there is no user intervention. Anyway, this seems to work. Crude but it works.
Ron