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

' 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

Related Function

MessageBeep

Category

Errors

Back to the index.


Last Modified: July 26, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information

Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/b/beep.html