Results 1 to 16 of 16

Thread: Sound Recorder

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Sound Recorder

    A simple Sound Recorder~

    1. Add Three buttons (button1, button2, button3) and a label (label1) to the form.
    2. Set the Text of Button1 to Start, Button2 to Stop, and Button3 to Play.
    3. Add this code:

    VB.NET Code:
    1. Public Class Form1
    2.  
    3.     Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.  
    7.         Button1.Enabled = False
    8.  
    9.         Button2.Enabled = True
    10.  
    11.         mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)
    12.  
    13.         mciSendString("record recsound", "", 0, 0)
    14.  
    15.         Label1.Text = "Recording..."
    16.  
    17.         Label1.Visible = True
    18.  
    19.     End Sub
    20.  
    21.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    22.  
    23.         Button1.Enabled = True
    24.  
    25.         Button2.Enabled = False
    26.  
    27.         Button3.Enabled = True
    28.  
    29.         mciSendString("save recsound c:\recsound.wav", "", 0, 0)
    30.  
    31.         mciSendString("close recsound", "", 0, 0)
    32.  
    33.         MsgBox("File Created: C:\recsound.wav")
    34.  
    35.         Label1.Text = "Stopped..."
    36.  
    37.         Label1.Visible = False
    38.  
    39.         My.Computer.Audio.Stop()
    40.  
    41.     End Sub
    42.  
    43.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    44.  
    45.         Label1.Text = "Playing..."
    46.  
    47.         Label1.Visible = True
    48.  
    49.         My.Computer.Audio.Play("c:\recsound.wav", AudioPlayMode.Background)
    50.  
    51.     End Sub
    52. End Class
    Attached Images Attached Images  
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width