How to: Play System Sounds in Visual Basic

This example uses the My.Computer.Audio.PlaySystemSound method to play a system sound.

The My.Computer.Audio.PlaySystemSound method takes as a parameter one of the shared members from the SystemSound class.

Example

Use the My.Computer.Audio.PlaySystemSound method to play the specified system sound.

The system sound Asterisk generally denotes errors. For more information, see SystemSound.

Sub PlaySystemSound()
    My.Computer.Audio.PlaySystemSound( 
        System.Media.SystemSounds.Asterisk)
End Sub

Compiling the Code

This code example can run only within a Windows Forms or console application. For more information, see PlaySystemSound.

See Also

Tasks

How to: Play Sounds in Visual Basic

How to: Play Looping Sounds in Visual Basic

How to: Determine if a File Exists in Visual Basic

Reference

System.Media.SystemSound

Stop