We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to produce a beep with the PC Speaker

AlexV
AlexV asked
on
Medium Priority
609 Views
Last Modified: 2010-08-05
How do I produce A beep from the PC Speaker using Visual Basic 4?  Beep produces a default wav sound (not PC speaker), MessageBeep API call does not work (gives an error of "Specified DLL function not found").
Comment
Watch Question

Commented:
Use the Beep Statment

Author

Commented:
As I said in the question, Beep uses the wav, not the PC Speaker.

Commented:
why not create your own wave file beep and send that to the output?
Maybe you've been using the wrong declaration, try this one:
Declare Function MessageBeep Lib "user32" Alias "MessageBeep" (ByVal wType As Long) As Long

The user can change those beeps!

Commented:
I think you must have your sound card set up in a way to take all pc sounds.  Because my pc sounds are not wired to go through the sound card - the 'beep' statement works quite fine, and through the pc's speaker.

:) D Perry

Commented:
Try:

Print CHR$(7);

Author

Commented:
Chr$(7) does not seem to work.  It just prints a black line on the form.

I don't make my own wav beep because the reason I want to use the PC Speaker is because the wav output is otherwise engaged, and can not be used.

User can change the beeps, but MessageBeep(-1) gives a PC Speaker Beep.

MikeP, thanks for your comment.  It seems I had it declared wrong; the place I had it copied from had Alias "BeepA" for some reason.  It works now.  I can't *accept* your answer as it was posted as a comment, but thanks none the less.

This seems to produce a click, rather than a beep, but that is allright.
Use

Const MB_IconHand = 16

MessageBeep(MB_IconHand)

and it should work

Regards,
Viktor Ivanov
Hey don't forget to turn on your PC Speakers =)

Regards,
Viktor Ivanov

Author

Commented:
MessageBeep 16 is not a PC Speaker beep, it is a wav beep.  Unless that event is unassigned in the windows sounds settings, in which case it is a PC Speaker beep.

Commented:
Well, I'd say you could use the Beep API; declared as folowing:
Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
In Windows95/98 the parametres dont matter since they are ignored anyways.

I hope this helps,
Patrik Husfloen

Author

Commented:
Sorry, this again produces a wav beep, if assigned (I think to "Windows Default Sound") in the sounds section of control panel.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.