Question Play audio?


New member
Nov 22, 2009
Programming Experience
Hi, i'm newbie in programing

i was created new project in, my project is change font colour a label and then play sound but when i press the same key the can't play and show error message "The header wave is corrupt". So can some body help to resolve my problem???

this my code:

Imports System.Media.SoundPlayer
Imports System.IO

Public Class Form1

Dim lbl() As Label
Dim sound() As Object

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
For i As Integer = 0 To lbl.Length - 1
lbl(i).ForeColor = Color.Black
If lbl(i).Text = e.KeyCode.ToString Then
lbl(i).ForeColor = Color.Pink
'My.Computer.Audio.Play(sound(i), AudioPlayMode.Background)
Exit Sub
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lbl = New Label() {L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, _
L11, L12, L13, L14, L15, L16, L17, L18, L19, L20, _
L21, L22, L23, L24, L25, L26}

sound = New Object() {My.Resources.Windows_Logon_Sound, My.Resources.Speech_Off, My.Resources.Speech_On}
End Sub
End Class
Top Bottom