Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95

View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?


"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP




Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: WAVMID in Category General VBA/VB6 : Multimedia from Total Visual SourceBook

Play WAV and MIDI sound files and record WAV files using the MCI (media control interface) API. Includes support for VB6 and VBA with 32 and 64 bit Windows API calls.

This class allows you to interact with WAV or MIDI files without using the Microsoft Multimedia Control.

Procedure List

Procedure Name



(Declarations) Declarations Declarations and private variables for the CWAVMID class
FileName Property Get the name of the file.
Length Property Get the play length of the sound file.
Position Property Get the position of the sound file.
Class_Terminate Terminate Close the MCI resource.
OpenWAV Method Open the WAV file. The filename property should be set before calling this procedure.
Pause Method Pause the WAV file.
Play Method Play the WAV file. The OpenWav procedure must be called before this procedure.
Record Method Record a WAV file. The FileName property must be defined before calling this method. This method saves the recording to the file specified in FileName.
Rewind Method Rewind the WAV file.
StopPlay Method Stop playing the WAV file.
CloseWAV Method Close the WAV file.

Example Code for Using Class: WAVMID

' Example of the CWAVMID Class
' To try this example, do the following:
' 1. Create a new form
' 2. Add a command button called 'cmdPlay'
' 3. Add a command button called 'cmdStop'
' 4. Add a command button called 'cmdPause'
' 5. Add a command button called 'cmdRewind'
' 6. Add a command button called 'cmdRecord'
' 7. Paste all the code from this example to the new form's module
' 8. Run the form

' This example assumes that the sample files are located in the folder named by the following constant.
Private Const mcstrSamplePath As String = "C:\TVSBSamp"

Private mclsWavMid As CWAVMID

Private Sub cmdPause_Click()
  If mclsWavMid Is Nothing Then
    CreateWavMidObject "Play"
  End If

  ' Pause playback
End Sub

Private Sub cmdPlay_Click()
  If mclsWavMid Is Nothing Then
    CreateWavMidObject "Play"
  End If

  ' Play the file
End Sub

Private Sub cmdRewind_Click()
  If mclsWavMid Is Nothing Then
    CreateWavMidObject "Play"
  End If

  ' Rewind the file
End Sub

Private Sub cmdStop_Click()
  If mclsWavMid Is Nothing Then
    CreateWavMidObject "Play"
  End If

  ' Stop the playback
End Sub

Private Sub CreateWavMidObject(ByRef strRecordOrPlay As String)
  Set mclsWavMid = New CWAVMID

  If strRecordOrPlay = "Play" Then
    ' set the filename
    mclsWavMid.FileName = mcstrSamplePath & "\test.wav"
    ' open the file
    mclsWavMid.FileName = mcstrSamplePath & "\testYourRecording.wav"
  End If

  ' Set the button captions
  cmdRecord.Caption = "Record"
  cmdPlay.Caption = "Play"
  cmdPause.Caption = "Pause"
  cmdStop.Caption = "Stop"
  cmdRewind.Caption = "Rewind"

End Sub

Private Sub cmdRecord_Click()
  Dim lngLastPointer As Long
  If mclsWavMid Is Nothing Then
    CreateWavMidObject "Record"
  End If
  'Save the last mousepointer in use
  lngLastPointer = Screen.MousePointer
  'Show hourglass
  Screen.MousePointer = vbHourglass

  'Record for 5 seconds
  mclsWavMid.Record (5000)
  'Close when we are done
  'Reset mousepointer
  Screen.MousePointer = lngLastPointer
End Sub

Private Sub Form_Load()
  Me.cmdPause.Caption = "Pause"
  Me.cmdPlay.Caption = "Play"
  Me.cmdStop.Caption = "Stop"
  Me.cmdRecord.Caption = "Record"
  Me.cmdRewind.Caption = "Rewind"
End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources