Solved

How to produce a beep with the PC Speaker

Posted on 1998-08-19
14
548 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").
0
Comment
Question by:AlexV
14 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1429791
Use the Beep Statment
0
 

Author Comment

by:AlexV
ID: 1429792
As I said in the question, Beep uses the wav, not the PC Speaker.
0
 
LVL 1

Expert Comment

by:wford
ID: 1429793
why not create your own wave file beep and send that to the output?
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1429794
Maybe you've been using the wrong declaration, try this one:
Declare Function MessageBeep Lib "user32" Alias "MessageBeep" (ByVal wType As Long) As Long

0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1429795
The user can change those beeps!
0
 
LVL 3

Expert Comment

by:dapperry
ID: 1429796
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
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1429797
Try:

Print CHR$(7);

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:AlexV
ID: 1429798
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1429799
Use

Const MB_IconHand = 16

MessageBeep(MB_IconHand)

and it should work

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1429800
Hey don't forget to turn on your PC Speakers =)

Regards,
Viktor Ivanov
0
 

Author Comment

by:AlexV
ID: 1429801
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.
0
 

Expert Comment

by:husfloen
ID: 1429802
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
0
 

Author Comment

by:AlexV
ID: 1429803
Sorry, this again produces a wav beep, if assigned (I think to "Windows Default Sound") in the sounds section of control panel.
0
 

Accepted Solution

by:
TrackZero earned 70 total points
ID: 1429804
in the old visual basics you could use the sounds statement

sound [int1],[int2]

produces a sound of [int1] Hz for [int2] secs.

don't know if this still works in these newer versions and have no means to check it myself right now
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now