Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2005, 10:04 PM
Registered User
 
Join Date: Oct 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default sound

I need a very easy way to play a sound without opening other programs. Help!!

Piranha
 
Old December 7th, 2005, 04:54 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

From Help:
Code:
Public Class SoundClass

   Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
      As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer

   ' name   specifies the sound file when the SND_FILENAME flag is set.
   ' hmod   specifies an executable file handle.
   ' hmod   must be Nothing if the SND_RESOURCE flag is not set.
   ' flags  specifies which flags are set. 

   ' The PlaySound documentation lists all valid flags.
   Public Const SND_SYNC = &H0          ' play synchronously
   Public Const SND_ASYNC = &H1         ' play asynchronously
   Public Const SND_FILENAME = &H20000  ' name is file name
   Public Const SND_RESOURCE = &H40004  ' name is resource name or atom

   ' Following method plays a sound from filename.
   Public Sub PlaySoundFile(ByVal filename As String)

      PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC)

   End Sub

End Class


Private Sub Button1_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles Button1.Click

   Dim SoundInst As New SoundClass()

   SoundInst.PlaySoundFile("C:\ringout.wav")

End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sound Frequency angelboy C# 2005 1 June 9th, 2009 01:21 AM
sound mohand Visual Basic 2005 Basics 1 November 27th, 2007 05:03 PM
Sound recorder kesitinhluoibieng Visual C++ 1 December 31st, 2006 09:08 AM
Sound on/off Adam H-W Flash (all versions) 1 June 27th, 2003 03:21 PM
Sound on demand Bill Javascript 2 June 10th, 2003 01:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.