|
-
May 31st, 2008, 10:16 PM
#1
Thread Starter
Junior Member
Continuous Beep program
I'm using the Beep function in kernel32.
Public Declare Function Beep Lib "kernel32" _
(ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
I use the code Beep 1000, 1000
But the problem is I want the beep to be continuous until a command button is pressed and the beep stops. How do I use the beep function to do this?
-
May 31st, 2008, 10:41 PM
#2
Re: Continuous Beep program
-
May 31st, 2008, 10:49 PM
#3
Re: Continuous Beep program
Beep in synchronous, so if its set to run for a second you can't just stop it until that duration is done, hence there will be a delay after you hit the stop button depending on how much duration of the beep is left.
add a public variable as a stop flag to the module,
Public StopBeep As Boolean
In your form you could maybe do this,
Code:
Private Sub Command1_Click()
' start beep
StopBeep = False
Do
DoEvents
If StopBeep = True Then Exit Do
Beep 1000, 1000
Loop
End Sub
Private Sub Command2_Click()
' stop beep
StopBeep = True
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|