Google Answers Logo
View Question
 
Q: How Do I Make a Sound using Visual Basic V6? ( Answered 3 out of 5 stars,   2 Comments )
Question  
Subject: How Do I Make a Sound using Visual Basic V6?
Category: Computers
Asked by: jem-ga
List Price: $15.00
Posted: 21 Sep 2002 15:51 PDT
Expires: 21 Oct 2002 15:51 PDT
Question ID: 67659
There is a "Beep" function which appears to be ideal. However, it doesn't
seem to have any effect whatsoever on my computer. I have already checked
that a sound is allocated to "Default Sound" within windows. The VB help
file says "The pitch and duration of the beep depend on your hardware and
system software, and therefore vary among computers". But this isn't very
helpful.

I am looking for any way of producing a sound on my computer using VB6. It
doesn't matter to me whether I use the Beep function or some other method.

Please feel free to ask for clarification if necessary.

$15 and enormous gratitude for the first correct solution. :)
Answer  
Subject: Re: How Do I Make a Sound using Visual Basic V6?
Answered By: davidmaymudes-ga on 21 Sep 2002 16:59 PDT
Rated:3 out of 5 stars
 
There are several ways to play sounds from within VB: the Beep method
should be playing the default sound, the same one as when various
errors occur--make sure your volume isn't turned down and that you
have a default beep chosen!  (The stuff about frequency & duration
varying refers to the old pre-sound-card built-in beep of IBM PCs,
which you don't tend to hear much any more unless your computer is
hung.)

This article explains how to use the sndPlaySound API to play a .wav
file:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q86281&FR=0

This article explains how to use the ActiveMovie control to play a .AU
file, but the same thing will work for .mp3, .wav, or even for video
files....

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q221578&

So this will let you make any sound you want, the only problem is that
you have to record your sound somehow and send it with your
application, or you can reference one of the files like "ding.wav"
that come with Windows.

searches used:
"visual basic play sound"
"visual basic play beep"


I hope that one of these methods is sufficient for you--if not, please
ask for a clarification and I'll try to find you something else!

Thanks,
David
jem-ga rated this answer:3 out of 5 stars
Hi David :) Thanks very much for your speedy work on this question. 
Strictly speaking, the answer you provided was correct however I have
two (very minor) quibbles: 1) If you had read the question correctly,
you would have noted that I stated at the beginning that "a sound is
allocated to "Default Sound" therefore your subsequent comment "make
sure....that you have a default beep chosen!" was somewhat redundant
and 2) the article you referenced at the following link:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q86281&FR=0
does not relate to Version 6 of Visual Basic (it refers to earlier
versions of Visual Basic and I did specifically state that I was
concerned with Version 6).  Again, aside from those two minor
quibbles, your answer was, strictly speaking, correct and the second
link you provided did get me started in the right direction so thanks
again for your quick and speedy efforts :)  For future reference, I
came across the following site which is an excellent resource for all
things Visual Basic: http://www.visualbasicforum.com

Comments  
Subject: Re: How Do I Make a Sound using Visual Basic V6?
From: rburra-ga on 23 Sep 2002 15:42 PDT
 
Try calling the beep function in a loop. You need to call the function
100-300 times, that produces an audible sound on most machines.
Subject: Re: How Do I Make a Sound using Visual Basic V6?
From: neilsmorr-ga on 28 Sep 2002 15:57 PDT
 
Is there some reason not to use a wav file? There are many of these in
the 'clip-art' section of Microsoft.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy