Beep Function

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

Platforms

Description & Usage

Beep plays a sound, but its exact behavior varies between platforms. Windows 95/98: The function always plays the SystemDefault system sound, regardless of the values passed to the function. Windows NT/2000: The function plays a tone through the computer's internal speaker at the desired frequency for a specified duration.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None

Parameters

dwFreq
Windows NT/2000: The frequency, in hertz (Hz), of the tone to play. Windows 95/98: Ignored.
dwDuration
Windows NT/2000: The duration, in milliseconds, to play the desired tone. Windows 95/98: Ignored.

Example

' This code is licensed according to the terms and conditions listed here.

' Attempt to play a note at 800 Hz for 2 seconds.  This will only
' behave this way on Windows NT/2000; users of Windows 95/98 will only hear the
' default sound.
Dim retval As Long  ' return value

retval = Beep(800, 2000)  ' ideally, an 800 Hz tone for 2 seconds

See Also

MessageBeep

Category

Errors

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: July 26, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/b/beep.html