sound when form opens

SpiN9823
01-20-2004, 08:08 PM
i have a file called "intro" and i want it to loop when the user starts my program... how can i do this?

SpiN9823
01-20-2004, 08:09 PM
also how would i make it play a music file called "goodbye" play when they closed my prog?

VBJoe
01-20-2004, 10:28 PM
Here's the code that Visual Studio 2003 help gives you when you search (in VS, click Help->Search) for "play sound":

Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.

' The PlaySound documentation lists all valid flags.
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom

Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC)
End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim SoundInst As New SoundClass()
SoundInst.PlaySoundFile("C:\ringout.wav")
End Sub

SpiN9823
01-22-2004, 09:53 AM
ok.... ill try that code when i get back to my house

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum