Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 41,204 times

Related Categories

Make the PC beep

It would appear at first that VB's standard Beep function would do just this. However, if a sound card is installed, even if the speakers are turned off, they will be used instead. To force the PC's internal speaker to sound, you need to use the Windows API beep function. Using this, you can even set the pitch and length of the beep.

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

To sound the beeper, simply use

Beep 500, 1000

The first value sets the frequency (or pitch). I find my PC's beeper performs best in the 500-3000 range. The second value is the duration of the beep in milliseconds (so 1000 is one second).

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Just a reply to most of the things i read

    Posted by Bobjmamin on 15 Jan 2007

    Hi my names chris barbour <bobjamin> and im new on this site but im far from new at programming ive programmed for about 6 or 7 years now and im 17 years old. I started with vi...

  • Re: [140] Help to display a form message before the PC beep sound!

    Posted by carina_a on 25 May 2006

    Hi,


    I have successfully get the beep sound out. However, how to display a form and then only the beep sound? Currently the beep sound is out before the form is displayed.Whe...

  • Two beeps

    Posted by Bladerun on 14 Sep 2005

    Is it possible to make VB create two tones at the same time?

  • its true

    Posted by black lem0n on 05 Feb 2005

    i am trying get a sound out of the internal pc speaker for 2 days and i am still trying. i have win 98, i consider myself prety advanced in vb language :). i searched more on google. i found a driver ...

  • Help with different OS'es

    Posted by Zaggy on 29 Apr 2004

    I coded a simple program that makes different tones, the programs runs fine on users with windows xp, but it gives the same tone all the time with ppl running Windows 98, what can I do to give em all ...