Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am new here and also new on VB.NET I created a project with some button and menu so now I want to play sound when cursor(mouse) is over the MENU option. What do I do?
Posted
Updated 17-Oct-12 3:42am
v2
Comments
Sergey Alexandrovich Kryukov 14-Oct-12 21:23pm    
As this is related to UI, you always need to tag your application type or UI library you want to use.
--SA
Akinmade Bond 17-Oct-12 9:40am    
And what can't you do? How to play the sound or how to create an event.

To play a system sound:
VB
System.Media.SystemSounds.systemsound.Play() 'Change systemsound into the sound that you need


To play a WAV file:
VB
Dim soundPlayer As New System.Media.SoundPlayer("sound.wav")
soundPlayer.Play() 'Change sound.wav into the file that you need


Hope this helps.
 
Share this answer
 
También puedes usar:

VB
Dim Sonido as String = Application.StartupPath & "\segundos30.wav"
My.Computer.Audio.Play(Sonido)
 
Share this answer
 
v2
Well First Thing Is Go To The Object Properties and click the lightning bolt.

Find the "MouseHover" event and double click it.

Now import the sound file into your VB.NET resources (must be a .wav file).

Now enter this code
VB
My.Computer.Audio.Play(My.Resources.sound)


all together your code should look like this

VB
Private Sub Button2_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.MouseHover
        My.Computer.Audio.Play(My.Resources.sound)
End Sub


Don't listen to these noobs who have lazy fingers :)

WOW WAY TO BE GIVING ME 1 STAR BECAUSE I HAVE THE RIGHT ANSWER.
 
Share this answer
 
v2
Comments
Akinmade Bond 17-Oct-12 9:42am    
:\

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900