بتدا يك كلاس به نام Class1 و یک فرم به نام form1 درست کن
سپس کد زیر را قرار بده
دکمه ها و ... با خودت
---------
در form1
Dim SndRecorder As New Class1
()Private Sub CmdRec_Click
SndRecorder.StartRecord
CmdRec.Enabled = False
CmdStopRec.Enabled = True
End Sub
()Private Sub CmdStopRec_Click
SndRecorder.StopRecord
CmdRec.Enabled = True
CmdStopRec.Enabled = False
End Sub
()Private Sub Form_Load
" SndRecorder.FileName = "C:\Sample.wav
End Sub
------
در class1
Private FName As String
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As
String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Enum MyState
Idle
Recording
Paused
End Enum
Private xState As MyState
Public Property Get FileName() As String
FileName = FName
End Property
(Public Property Let FileName(ByVal sFileName As String
FName = sFileName
End Property
Public Function StartRecord() As Boolean
: On Error GoTo ER
: If FName = "" Then GoTo ER
Dim RS As String, cb As Long, I As Long
( RS = Space$(1024
( I = mciSendString("open new type waveaudio alias capture", RS, 1024, cb
( I = mciSendString("record capture", RS, 1024, cb
xState = Recording
StartRecord = True
Exit Function
:ER
StartRecord = False
End Function
Public Function StopRecord() As Boolean
: On Error GoTo ER
: If FName = "" Then GoTo ER
Dim RS As String, cb As Long, I As Long
(RS = Space$(1024
( I = mciSendString("save capture " & FName, RS, 1024, cb
( I = mciSendString("close capture", RS, 1024, cb
xState = Idle
StopRecord = True
Exit Function
: ER
( I = mciSendString("close capture", RS, 1024, cb
StopRecord = False
End Function
()Private Sub Class_Initialize
xState = Idle
End Sub
()Private Sub Class_Terminate
StopRecord
End Sub
Public Function PauseRecord() As Boolean
: On Error GoTo ER
: If FName = "" Then GoTo ER
Dim RS As String, cb As Long, I As Long
(RS = Space$(1024
If xState = Paused Then
(I = mciSendString("record capture", RS, 1024, cb
xState = Recording
ElseIf xState = Recording Then
(I = mciSendString("pause capture", RS, 1024, cb
xState = Paused
End If
PauseRecord = True
Exit Function
:ER
PauseRecord = False
End Function
Public Property Get State() As MyState
State = xState
End Property