Solved

How to produce a beep with the PC Speaker

Posted on 1998-08-19
14
552 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

763 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