How do i do to Make a Select Beep sound and when is selected and i press button1 it will make the sound i choose.

Recommended Answers

All 10 Replies

You can call Console.Beep() to make the computer beep. This will use the internal speaker of the computer. If you want to play a custom sound you will need to use the computer's external speaker. To play a WAV file user the SoundPlayer class:

private void button2_Click(object sender, EventArgs e)
    {
      using (System.Media.SoundPlayer sp = new System.Media.SoundPlayer(@"C:\filename.wav"))
      {
        sp.Play();
      }
    }

You can call Console.Beep() to make the computer beep. This will use the internal speaker of the computer. If you want to play a custom sound you will need to use the computer's external speaker. To play a WAV file user the SoundPlayer class:

private void button2_Click(object sender, EventArgs e)
    {
      using (System.Media.SoundPlayer sp = new System.Media.SoundPlayer(@"C:\filename.wav"))
      {
        sp.Play();
      }
    }

{

}

im in VB.NET

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Console.Beep()
		Dim sp As New System.Media.SoundPlayer("C:\filename.wav")
		sp.Play()
		sp.Dispose()
	End Sub
commented: Reputation for helping me. +1

Thank You it works but now i have 2 little question

First how can i make it sound without a Location or Site ? like i click on
Add Existing Item i select the beep.wav i have

and the other was how can i do that when beep sound finish to do it again without stoping like Do Loop but not 2 fast cuz the other time i put loop thingy and this was beeping like crazy even when i close it continues beeping.

By now ima add you a Rep + Vote

You can embed the wav files into your project by adding them to the project Resources.

i have it in my resourcers but im trying to make it work.

if i put the Beep sound by location when i go to my other pc and i put the program it wont sound the beep sound i put, it will make the default pc beep.

ok i make it work by Resource and i try it in my other pc and it works
now how i make the TrackBar1 is the volume of the beep ?

xfrolox,

You should create new threads for new questions so this thread doesn't continue to grow until your project finishes up :)

You will need to make calls to the unmanaged win32 API in order to adjust the volume but I would not recommend doing that. A user sets their speaker volume on the windows system tray and by the volume on their speakers to what is acceptable. Anymore there can get to be 10 levels of volume control and you see people just crank all of them up so they can control volume in a single place.

Article on MSDN:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/42b46e40-4d4a-48f8-8681-9b0167cfe781

ok,,, then ill put this as solve cuz you help me in the first question of putting custom beeps now ima try it alone if i can't ill made a new thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.