Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 105,763 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 1,702 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!




Computer beep using API

A method for using the Windows API to create a internal speaker beep.

Submitted By: jayman9
Actions:
Rating:
Views: 6,182

Language: VB.NET

Last Modified: August 9, 2006
Instructions: Make sure that you import the following for this to work:

Imports System.Runtime.InteropServices

Snippet


  1. 'put this code just below the class level
  2.    
  3.     <DllImport("KERNEL32.DLL", EntryPoint:="Beep", SetLastError:=True, _
  4.     CharSet:=CharSet.Unicode, ExactSpelling:=True, _
  5.     CallingConvention:=CallingConvention.StdCall)> _
  6.        Public Shared Function _
  7.        aBeep(ByVal dwFreq As Integer, ByVal dwDuration As Integer) _
  8.          As Boolean
  9.         ' Leave the body of the function empty.
  10.     End Function
  11.  
  12.  
  13. 'now make a call to the Function with Frequency
  14. 'and Duration parameters. Can be used anywhere you want
  15. 'to alert the user. 
  16.  
  17.         aBeep(1000, 500)
  18.         aBeep(2000, 1000)
  19.  
  20.  

Copy & Paste


Comments


BlackBeltPilot 2008-01-07 10:49:30

This little snippet does exactly what I wanted it to do, play a beep on the internal pc speaker using VB.


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month