I am a self-taught VB programmer and have found these forums invaluable. Usually the solution can be found here and I am happy - but this is causing me some trouble...

I want to play a sound, using Media player, twice - one after the other.

I have written a sub that make the sound, and called it 'sound()'

When I put

sound()
sound()

in the code, it only playes once.
If I put an empty for-next loop, it still only plays once, but if I put a msgbox() inbetween them, they both play.

I am sure I am being thick, but any ideas??

Code now reads...

 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Knock()
        System.Threading.Thread.Sleep(1000)
        Knock()

    End Sub

When I click the button, I still only get one click, but after a pause...

What is the code behind Knock()? You could always create a sound file that has the desired sound repeated. Then you would only have to call the routine once as

KnockKnock()

`Private Sub Knock()

    AxWindowsMediaPlayer1.URL = "c:\knock.mp3"
    AxWindowsMediaPlayer1.Ctlcontrols.play()

End Sub`

That is the code for knock()

It may be that your subroutine "Sound()" does not terminate properly, and as a result it does not initialize the second time. check your code in that subroutine

This article has been dead for over six months. Start a new discussion instead.