Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / March 2010



Tip: Looking for answers? Try searching our database.

PLaying sound.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Henry Wilson - 07 Mar 2010 11:35 GMT
I want to write a VB6 program that allows me to play a short sound when I click
a form. The file will have been previously created and stored as a file.

Is this possible ? If so, is there a limitation on what kind of files can be
played?

'Help' is very vague on this. I cannot seem to do it using 'sound.note' and
'sound.play'...I just get error messages.
Auric__ - 07 Mar 2010 18:45 GMT
> I want to write a VB6 program that allows me to play a short sound when
> I click a form. The file will have been previously created and stored as
[quoted text clipped - 5 lines]
> 'Help' is very vague on this. I cannot seem to do it using 'sound.note'
> and 'sound.play'...I just get error messages.

Look into the sndPlaySound API. MSDN info:
 http://msdn.microsoft.com/en-us/library/aa909803.aspx

Signature

I don't have an attitude problem. You have a perception problem.

Henry Wilson - 07 Mar 2010 21:45 GMT
>> I want to write a VB6 program that allows me to play a short sound when
>> I click a form. The file will have been previously created and stored as
[quoted text clipped - 8 lines]
>Look into the sndPlaySound API. MSDN info:
>  http://msdn.microsoft.com/en-us/library/aa909803.aspx

Thanks.

What is missing here?
I copy the example code provided into a simple VB6 form:

Private Sub Form_Click()
PlaySound (TEXT("\\SOUNDS\\chimes.WAV") , NULL, SND_SYNC);
End Sub

...and get a syntax error message.

The file exists. Do I have to identify it in another way?
Auric__ - 08 Mar 2010 13:43 GMT
>>> I want to write a VB6 program that allows me to play a short sound
>>> when I click a form. The file will have been previously created and
[quoted text clipped - 21 lines]
>
> The file exists. Do I have to identify it in another way?

Non-language-specific sample code on MSDN is in C++, not VB. You need to
change the sample to something like this:
 Public Const SND_SYNC = &H0
 Private Sub Form_Click()
   PlaySound ("path\to\wavefile.wav", vbNull, SND_SYNC)
 End Sub

AllAPI has a some VB sample code here:
 http://allapi.mentalis.org/apilist/PlaySound.shtml

Go to the bottom and click the example link.

Signature

- Strictly speaking, it's better than the alternative...
- ...yet someone is clearly doing their job horribly wrong.

Henry Wilson - 08 Mar 2010 20:24 GMT
>>>> I want to write a VB6 program that allows me to play a short sound
>>>> when I click a form. The file will have been previously created and
[quoted text clipped - 33 lines]
>
>Go to the bottom and click the example link.

Fantastic!

Thanks for that....

It will only play .wav files, I gather.
Auric__ - 08 Mar 2010 21:13 GMT
>>>>> I want to write a VB6 program that allows me to play a short sound
>>>>> when I click a form. The file will have been previously created and
[quoted text clipped - 39 lines]
>
> It will only play .wav files, I gather.

I don't know. I don't use sounds in my programs. Ever. (The docs seem to
suggest that other formats are supported, but don't say what. Give it a try
with whatever format you want to use and see what happens.)

--
I never could bring myself to trust a traitor.
Not even a traitor I created.
Henry Wilson - 08 Mar 2010 22:36 GMT
>>>>>> I want to write a VB6 program that allows me to play a short sound
>>>>>> when I click a form. The file will have been previously created and
[quoted text clipped - 41 lines]
>
>I don't know. I don't use sounds in my programs. Ever.

I haven't until now either.

>(The docs seem to
>suggest that other formats are supported, but don't say what. Give it a try
>with whatever format you want to use and see what happens.)

It doesn't seem to want to play wma. That's OK. I can save all the sounds as
.wav

thanks for the help.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.