How to: Stop Playing Sounds in the Background in Visual Basic
This example stops a sound playing in the background.
In general, when an application plays a looping sound, it should stop the sound at some point.
Use the My.Computer.Audio.Stop method to stop the application's currently playing background or looping sound.
Sub StopBackgroundSound() My.Computer.Audio.Stop() End Sub
This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Windows Forms Applications > Sound. For more information, see How to: Insert Snippets Into Your Code (Visual Basic).
Compiling the Code
This code example can run only within a Windows Forms or console application. For more information, see My.Computer.Audio.Stop Method.