How to: Retrieve Audio Resources in Visual Basic

You can retrieve the audio resources of an application by accessing the resource's property on the My.Resources object.

The My.Resources object exposes each resource as a read-only property. The property name is the same as the resource name, and the property type is determined by the resource classification. For more information, see My.Resources Object.

Example

This example uses the My.Computer.Audio.Play method to play the sound stored as an audio resource named Form1Greeting in the application's resource file.

Sub PlayFormGreeting()
    My.Computer.Audio.Play(My.Resources.Form1Greeting, 
        AudioPlayMode.Background)
End Sub

For this example to work, your application must have an audio resource named Form1Greeting in the application's resource file. For more information, see How to: Add or Remove Resources.

The My.Computer.Audio.Play method is available only for Windows Forms applications. For more information, see Play.

See Also

Tasks

How to: Retrieve String Resources in Visual Basic

How to: Retrieve Image Resources in Visual Basic

How to: Retrieve Icon Resources in Visual Basic

How to: Retrieve Localized Resources in Visual Basic

Reference

My.Resources Object

Audio.Play

Other Resources

Managing Application Resources