Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,039 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,633 people online right now. 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: Jayman
Actions:
Rating:
Views: 8,304

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.




Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month