Solved

How to produce a beep with the PC Speaker

Posted on 1998-08-19
14
550 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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
 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

776 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