473,382 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

sound effects?

hey, im wodering if anyone knows how i can play a soundin my VB.net windows
app when a Form1_Click event is triggered? thanks
Nov 21 '05 #1
5 2596
See Windows Forms Tips and Tricks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
hey, im wodering if anyone knows how i can play a soundin my VB.net
windows
app when a Form1_Click event is triggered? thanks

Nov 21 '05 #2
thanks but im still a n00b programmer, anything simpler?
Nov 21 '05 #3
iwdu15

DirectX 9c SDK, however it is not simple.

If it is only playing a wav file, than use the standards for that.

I hope that helps,

Cor
Nov 21 '05 #4
The example is pretty simple. It does involve some interop but that's just a
declaration of an imported method from a DLL that exists in the system. The
important bits are:

<DllImport("Winmm.dll")> _
Shared Function sndPlaySound(lpszSound As String, fuSound As Integer) As
Integer
End Function

Then, in a click handler or wherever you want to play the sound...

sndPlaySound("<your sound file path goes here>", 1)

That's even good enough for beginners... :-)
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
thanks but im still a n00b programmer, anything simpler?

Nov 21 '05 #5
Hi. This is old VB6 stuff which works OK in desktop .Net ...

Declare this function:

Public Declare Auto Function PlaySound Lib "winmm.dll" (ByVal
ByVallpszSoundName As _

String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer

Call function:

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Click

PlaySoundChimes

End Sub

Public Sub PlaySoundChimes()

On Error Resume Next

Dim fileName As String = String.Concat("F:\chimes.wav")

Const SND_FILENAME As Integer = &H20000

PlaySound(fileName, 0, SND_FILENAME)

End Sub

Graeme

"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
hey, im wodering if anyone knows how i can play a soundin my VB.net
windows
app when a Form1_Click event is triggered? thanks

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Mantorok Redgormor | last post by:
Can emulation of the logical OR be done in standard C to obfuscate its use? So I don't have to use if(a||b) but instead make that even more obfuscated without its use but testing the same condition
5
by: djc | last post by:
what choices do I have to play sounds in a program using vb.net? Or, I guess if nothing vb specific what windows API(s) should I look at? I am interested to find out whats needed for playing short...
2
by: positivebalance41m | last post by:
I have been searching how to do sound capture (record audio input) in VB.NET for days now. I find some references to "winmm.dll" calls, but they give VB5 or VB6 examples which won't code convert...
10
by: Immortalist | last post by:
Various aquisition devices that guide learning along particular pathways towards human biases. And as E.O. Wilson might say mental development appears to be genetically constrained. (1) Language...
4
mrnn
by: mrnn | last post by:
Hello, just one last issue i'd like to figure out for my game...i'm tryin to figure out how to play sound effects in the game. i know how to get background music but for sounds i'd like it somethin...
5
by: | last post by:
Hello, I am wrtting a program that does some sound effects... the files are stored in a subfolder in the application folder... and I check the existence of the files before calling the method to...
26
by: Jake Barnes | last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching for "how to play a sound with Javascript". I'm somewhat suprised that the majority of entries are from the 1990s, and there are...
4
by: kid joe | last post by:
Hello I've got interested in learning some basic sound programming bits in C... mainly I want to know how to go about accessing the sound devices - reading from them mainly - in windows and...
4
by: themadme | last post by:
Is it possible to be able to produce real sound time effects, for example ( bullets hitting off different materials ). Has it already been done?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.