User Form pop up with a beep?

D

Don Wiss

I'd like a User Form to make the same beep as a MsgBox makes when it pops
up. I tried the word Beep in front of my User Form show, but I got no
sound.

Don <www.donwiss.com> (e-mail link at home page bottom).
 
G

Gary Keramidas

you have events turned off or something? make a new form and just add these
lines of code to it, it should work.
 
T

Tom Ogilvy

Beep works for me - do you have your speakers turned down./off, headphones
plugged in.

Is the messagebox audible.

Here is a way to do it with the API (but the speakers have to be on).

In NT/XP/2003, you can control the internal speaker (which makes the beep)

Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, _
ByVal dwDuration As Long) As Long


Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single
num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)


For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub


The first argument is the frequency. You can change the 10000 (you can't
hear that) to 1000 to get a different affect for example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top