Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beep frequencies and length

Status
Not open for further replies.

RonVaught

Programmer
Oct 22, 2002
62
US
Does anyone know how to make a Beep / Tone that allows different frequencies / sounds and also be able to set the length of the Beep / Tone?
 
To have a longer beep try something like this

Sub ManyBeeps (NumOfBeeps as Integer)
Dim I as Integer

For I = 1 To NumOfBeeps
Beep
Next I
End Sub

Then call it like this

ManyBeeps 5 ' Do 5 beeps

Hope that helps you

Dave
 
You might want to try using the Beep API call which accepts both a frequency and duration parameters

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

That being said, it may not work on all versions of Windows, For example, AFAIK, the duration parameter is ignored under Win95. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks for your reply. Not exactly what I was looking for though. . . After playing around with the Beep API function I was able to find what I was looking for. See Sample code below.

Option Explicit
Private Declare Function Beep Lib "kernel32.dll" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Private Sub Command1_Click()

Dim iFreq As Integer
Dim iLenght As Integer ' milliseconds

iFreq = 100

iLenght = 50

Do Until iFreq > 4500
Beep iFreq, iLenght
iFreq = iFreq + 100
Loop

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top