Search Tools Links Login

All About Beep API [Article]


Visual Basic 6, or VB Classic

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!!

Original Author: MadWizardBD

Code

 


All About
Beep API


Introduction

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



Freq=11000

Duration=1000

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!



Conclusion

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 MadWizardBD@hotmail.com. I'll be happy to help you. LET ME KNOW WHAT
DO YOU THINK!!! AND NEVER FORGET TO RATE!!


About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 119 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.