Click here to Skip to main content
13,090,730 members (43,934 online)
Rate this:
 
Please Sign up or sign in to 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 14-Oct-12 7:19am
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
geekbond 17-Oct-12 9:40am
   
And what can't you do? How to play the sound or how to create an event.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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


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


Hope this helps.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

También puedes usar:

Dim Sonido as String = Application.StartupPath & "\segundos30.wav"
My.Computer.Audio.Play(Sonido)
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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
My.Computer.Audio.Play(My.Resources.sound)


all together your code should look like this

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.
  Permalink  
v2
Comments
geekbond 17-Oct-12 9:42am
   
:\

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100