borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (how to detect how many check box is checked on a particular column of datagrid?)Next Topic (Dataset related question?) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : Sound in a form
Poster Message
patriciam
Level: Guest


icon Sound in a form

Hi!
How can i put sound in a form?What is the better object to use?
Tanks!

05-01-2004 at 11:49 AM
| Quote Reply
Chris_871
Level: Master


Registered: 30-11-2002
Posts: 106
icon Re: Sound in a form

Hi
You can use Beep() function to make a sound in a form.

To play a wave file in VB 6.0 ,

Declare a following API function,

Declare Function mciExecute Lib "winmm.dll" (ByVal strFilename As String) As Integer

Then write the following code into the button click event,

Dim pl As Integer
pl = mciExecute("play " & "c:windowsmedialogoff.wav")

It works under VB 6.0, Please check with .Net.

by
Chris



[Edited by Chris_871 on 06-01-2004 at 03:41 PM GMT]

[Edited by Chris_871 on 08-01-2004 at 12:07 PM GMT]

06-01-2004 at 10:40 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: Sound in a form

It seems that .NET doesnt provide classes to play sound. Therefore, you would have to use API function sndPlaySound in order to do it.

____________________________
If you find the answer helpful, please mark this topic as solved.

06-01-2004 at 11:35 AM
View Profile Send Email to User Show All Posts | Quote Reply
patriciam
Level: Guest

icon Re: Sound in a form

How i use that function sndPlaySound ?
Can you give me an example?

06-01-2004 at 01:04 PM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: Sound in a form

It should be the same as in VB6

Module Module1
    Const SND_ASYNC = &H1
    Const SND_NODEFAULT = &H2

    Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

    Public Sub PlaySound(ByVal FileName As String)
        sndPlaySound(FileName, SND_ASYNC Or SND_NODEFAULT)
    End Sub
End Module


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PlaySound("C:\WINDOWS\Application Data\Microsoft\WELCOME\WELCOM98.WAV")
    End Sub


____________________________
If you find the answer helpful, please mark this topic as solved.

07-01-2004 at 04:48 PM
View Profile Send Email to User Show All Posts | Quote Reply
patriciam
Level: Guest

icon Re: Sound in a form

That function is just for .wav files?I tried with a mp3 file and it doesn't work.

08-01-2004 at 04:40 PM
| Quote Reply
AndreaVB Forum : VB.Net : Sound in a form
Previous Topic (how to detect how many check box is checked on a particular column of datagrid?)Next Topic (Dataset related question?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder