All About Beep API [Article]

Submitted on: 1/27/2015 10:24:00 PM
By: MadWizardBD (from psc cd)  
Level: Beginner
User Rating: By 13 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 484
     U may assume that Beep API can only be used 4 beeping. But, wait there's more what you can do with this API. You can also drive the mosquitos away using this technique! Check it out now! AND NEVER FORGET TO RATE!!



All About Beep API

Today we will discuss about the Beep API which is very simple to use. You may think that what the Beep API can do without beeping. But, wait there's more what you can do with this API. You can also drive the mosquitos away using this technique! Let's have a look at them.

The Beep API
The function is synchronous, so it doesn't return control to its caller until the sound finishes. Actually if you have Win9x OS such as Windows95/98/ME, there is nothing more you can do than beeping with this API. So, it would be better if you use the built-in VB command 'beep' instead of using Beep API. You can generate 37Hz to 32768Hz (inclusive) frequency on WinNT/2000/XP and it is up to you how long your VB program will generate this frequency using your PC Speaker. Let's take a look at this one of the simpliest APIs use...

Private Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal _
dwFreq As Long, ByVal dwDuration As Long) As Long

Private Sub Form_Load()

'36 < Frequency < 32768 and Duration in miliseconds.
' here we are using Frequency=11000 and Duration = 1000
'so set the variable

ai = Beep(Freq,Duration)

'if success ai <> 0

End Sub

In this code, first we have declared the Beep API and set the arguments to pass. The first argument it takes is dwFreq, and the last one is dwDuration. As we would like to generate 11KHz of frequency for 1 second. We've just simply set variable to pass. Here you should remember that the dwDuration argument is in miliseconds. So, if you set this to 1000, it will generate sound for 1 second. So, you can also drive the mosquitos away using this technique!

And this is exactly all about. Hope I'll introduce you with few good stuffs in VB programming. Never forget to contact me for any question, comments regarding Win32 API, VB, Java etc. Contact me without hesitation. My email address is I'll be happy to help you. LET ME KNOW WHAT DO YOU THINK!!! AND NEVER FORGET TO RATE!!

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.