Voice Recorder in Visual Basic .NET

Create a new form and add 3 button to your form and Rename the buttons as the following: Record, Save and Play as shown below:

 
 
Go to the code page and add the following declaration: 
  1. Private Declare Function record Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As StringByVal lpstrReturnString As StringByVal uReturnLength As IntegerByVal hwndCallback As IntegerAs Integer  
Record Button Code
  1. Private Sub Record_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
  2.     record("open new Type waveaudio Alias recsound""", 0, 0)  
  3.     record("record recsound""", 0, 0)  
  4. End Sub  
Stop and Save Button Code
  1. Private Sub Stop_and_Save_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button2.Click  
  2.     record("save recsound D:\Manish\mbp.wav""", 0, 0)  
  3.     record("close recsound""", 0, 0)  
  4. End Sub  
Play Button Code
  1. Private Sub Play_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button3.Click  
  2.     My.Computer.Audio.Play("D:\Manish\mbp.wav", AudioPlayMode.Background)  
  3. End Sub  
Ebook Download
View all
Learn
View all