Stop my sound

  • Follow


I'm using the following code to play a sound or music in a game I made for my 
class, however I don't always want to wait for the sound or song to finish.  
How can I stop the song/sound?  Need code to stop a sound/song from 
completing.  Or would I use some type of Exit Sub procedure?  If so, don't 
know how to code.

Dim RandomSong As Integer

Sub PlayRandomSong()
RandomSong = Int((4 - 1 + 1) * Rnd + 1)
If RandomSong = 4 Then
CenterField
ElseIf RandomSong = 3 Then
StadiumCheer
ElseIf RandomSong = 2 Then
TakeMeToBallGame
ElseIf RandomSong = 1 Then
Booing
End If
End Sub

Sub CenterField()
Call sndPlaySound32 _
("C:\centerfield", 0)
End Sub

Sub TakeMeToBallGame()
Call sndPlaySound32 _
("C:\outtoballgame", 0)
End Sub

Sub StadiumCheer()
Call sndPlaySound32 _
("C:\stadiumroar", 0)
End Sub

Sub Booing()
Call sndPlaySound32 _
("C:\booing", 0)
End Sub
-- 
Mike Mast
Special Education Preschool Teacher
0
Reply Utf 4/6/2010 12:46:03 AM

You shouldn't need to do it in code. You can set any button to play the 
sound "Stop all sounds," I believe. This should stop whatever is 
playing. Plus, if that same button needs to run VBA or do a hyperlink, 
it should be able to do that, too.
--David

On 4/5/10 8:46 PM, Preschool Mike wrote:
> I'm using the following code to play a sound or music in a game I made for my
> class, however I don't always want to wait for the sound or song to finish.
> How can I stop the song/sound?  Need code to stop a sound/song from
> completing.  Or would I use some type of Exit Sub procedure?  If so, don't
> know how to code.
>
> Dim RandomSong As Integer
>
> Sub PlayRandomSong()
> RandomSong = Int((4 - 1 + 1) * Rnd + 1)
> If RandomSong = 4 Then
> CenterField
> ElseIf RandomSong = 3 Then
> StadiumCheer
> ElseIf RandomSong = 2 Then
> TakeMeToBallGame
> ElseIf RandomSong = 1 Then
> Booing
> End If
> End Sub
>
> Sub CenterField()
> Call sndPlaySound32 _
> ("C:\centerfield", 0)
> End Sub
>
> Sub TakeMeToBallGame()
> Call sndPlaySound32 _
> ("C:\outtoballgame", 0)
> End Sub
>
> Sub StadiumCheer()
> Call sndPlaySound32 _
> ("C:\stadiumroar", 0)
> End Sub
>
> Sub Booing()
> Call sndPlaySound32 _
> ("C:\booing", 0)
> End Sub


-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/6/2010 1:13:12 AM

1 Replies
398 Views

(page loaded in 0.08 seconds)

Similiar Articles:
















7/26/2012 9:06:33 AM


Reply: