From: Preschool Mike on 5 Apr 2010 20:46 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
From: David Marcovitz on 5 Apr 2010 21:13 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
|
Pages: 1 Prev: I want to burn a presention to a cd but the sound does not come o Next: Gradient |