קח את הקוד הזה ותוסיף שני לחצנים...
Option Explicit 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 Private Declare Function mciGetErrorString Lib ``winmm.dll`` _ Alias ``mciGetErrorStringA`` _ (ByVal dwError As Long, _ ByVal lpstrBuffer As String, _ ByVal uLength As Long) As Long Private Sub CloseSound() Dim Result& Dim errormsg% Dim ReturnString As String * 1024 Dim ErrorString As String * 1024 Result& = mciSendString(``close mysound``, ReturnString, 1024, 0) End Sub Private Sub RecordSound() `records sound aliased as mysound to memory for six seconds Dim Result& Dim errormsg% Dim ReturnString As String * 1024 Dim ErrorString As String * 1024 CloseSound Result& = mciSendString(``open new type waveaudio alias mysound``, ReturnString, 1024, 0) If Not Result& = 0 Then errormsg% = mciGetErrorString(Result&, ErrorString, 1024) MsgBox ErrorString, 0, ``Error`` Exit Sub End If Result& = mciSendString(``set mysound time format ms bitspersample 8 samplespersec 11025``, ReturnString, 1024, 0) If Not Result& = 0 Then errormsg% = mciGetErrorString(Result&, ErrorString, 1024) MsgBox ErrorString, 0, ``Error`` Exit Sub End If `Record for 60000 milliseconds Result& = mciSendString(``record mysound to 60000``, ReturnString, 1024, 0) If Not Result& = 0 Then errormsg% = mciGetErrorString(Result&, ErrorString, 1024) MsgBox ErrorString, 0, ``Error`` Exit Sub End If End Sub Private Sub PlayRecSound() `plays the recoreded sound aliased by mysound Dim Result& Dim errormsg% Dim ReturnString As String * 1024 Dim ErrorString As String * 1024 Result& = mciSendString(``stop mysound``, ReturnString, 1024, 0) If Not Result& = 0 Then errormsg% = mciGetErrorString(Result&, ErrorString, 1024) MsgBox ErrorString, 0, ``Error`` End If Result& = mciSendString(``play mysound from 1 wait``, ReturnString, 1024, 0) If Not Result& = 0 Then errormsg% = mciGetErrorString(Result&, ErrorString, 1024) MsgBox ErrorString, 0, ``Error`` End If End Sub Private Sub Command1_Click() Call RecordSound End Sub Private Sub Command2_Click() Call PlayRecSound End Sub Private Sub Form_Unload(Cancel As Integer) CloseSound End Sub