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: CD in Category General VBA/VB6 : Multimedia from Total Visual SourceBook

Class to provide an interface for controlling a CD player without using the Microsoft Multimedia Control. Includes support for VB6 and VBA 32 and 64 bit API calls.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CCD class
Minutes Property Get the minute position of the CD.
Seconds Property Set the seconds position of the CD.
Track Property Set the track position.
Tracks Property Get the tracks collection. The Tracks collection contains an item for each track on the CD. The data stored in each item is the length of the track in seconds.
Class_Initialize Initialize Set initial values.
Class_Terminate Terminate Close the CD resources
CloseCD Method Close the CD resource.
Eject Method Eject the CD from the drive.
OpenCD Method Open the CD resource.
Pause Method Pause CD Play.
Play Method Play the CD.
StopCD Method Stop the CD.
dblToLong Private This routine does an unsigned conversion from a Double value to a Long value. This function correctly handles doubles greater than 2,147,483,647 and less than or equal to 4,294,967,295.
EnumTracks Private Enumerate the tracks on a CD.
GetPosition Private Get the current position of the playback of the MCI device.
IntToByte Private Perform an unsigned conversion from an integer value to a byte value.
IntToLong Private Convert an integer value to a long value, treating the integer as unsigned.
LongToDbl Private Convert a long integer value to a double, treating the long as unsigned.
LongToInt Private Perform an unsigned conversion from a long integer value to an integer value.
MCI_MAKE_TMSF Private Convert from Track/Minute/Seconds to a position usable by MCI.
MCI_TMSF_MINUTE Private Convert a position returned from MCI to a minute values.
MCI_TMSF_SECOND Private Convert a position returned from MCI to a seconds value.
MCI_TMSF_TRACK Private Convert a position returned from MCI to a track value.
SetPosition Private Set the current position of the MCI playback.
Shli Private Shift an integer value left by the specified number of bits. Left shifting is a multiplication operation. For the number of bits to shift to the left, raise two to that power, then multiply the result by the original value.
Shll Private Shift a long integer value left by the specified number of bits. Left shifting is a multiplication operation. For the number of bits to shift to the left, raise two to that power, then multiply the result by the original value.
Shri Private Shift a long integer value right by the selected number of places. Right shifting is a division operation. For the number of bits to shift to the right, raise two to that power, then divide the original value by the result.
Shrl Private Shift a long integer value right the selected number of places. Right shifting can be defined as a division operation. For the number of bits to shift a value to the right, raise two to that power, then divide our original value by the result.

Example Code for Using Class: CD

' Example of the CCD class
'
' To use this example:
' 1. Create a new form.
' 2. Create a command button called 'cmdPlay'
' 3. Create a command button called 'cmdPause'
' 4. Create a command button called 'cmdStop'
' 5. Create a command button called 'cmdBackTrack'
' 6. Create a command button called 'cmdBack'
' 7. Create a command button called 'cmdForward'
' 8. Create a command button called 'cmdForwardTrack'
' 9. Create a command button called 'cmdEject'
' 10. Create a command button called 'cmdPower'
' 11. Create a combo box called 'cboTracks'
' 12. Paste the entire contents of this module into the new form's module.

Private mcd As CCD

Private Sub CreateCDObject()
  ' Instantiate the CCD object
  Set mcd = New CCD
End Sub

Private Sub cboTracks_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  mcd.Track = cboTracks.ListIndex + 1
  mcd.Minutes = 0
  mcd.Seconds = 0
End Sub

Private Sub cmdBack_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  mcd.Seconds = mcd.Seconds - 1
End Sub

Private Sub cmdBackTrack_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  If mcd.Track > 1 Then
    mcd.Track = mcd.Track - 1
    mcd.Minutes = 0
    mcd.Seconds = 0
  End If
End Sub

Private Sub cmdEject_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  mcd.Eject
  mcd.CloseCD
End Sub

Private Sub cmdForward_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  mcd.Seconds = mcd.Seconds + 1
End Sub

Private Sub cmdForwardTrack_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  If mcd.Track < mcd.Tracks.Count Then
    mcd.Track = mcd.Track + 1
    mcd.Minutes = 0
    mcd.Seconds = 0
  End If
End Sub

Private Sub cmdPause_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  mcd.Pause
End Sub

Private Sub cmdPlay_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If
  mcd.Play
End Sub

Private Sub cmdPower_Click()
  Dim intTrackCounter As Integer

  If mcd Is Nothing Then
    CreateCDObject
  End If

  mcd.OpenCD

  ' If tracks exist, then populate combo
  If Not mcd.Tracks Is Nothing Then

    For intTrackCounter = 1 To mcd.Tracks.Count
      cboTracks.AddItem "Track " & intTrackCounter
    Next intTrackCounter

    cboTracks.ListIndex = 0

  End If

End Sub

Private Sub cmdStop_Click()
  If mcd Is Nothing Then
    CreateCDObject
  End If

  mcd.StopCD
End Sub

Private Sub Form_Load()
  Me.cmdBack.Caption = "Back"
  Me.cmdBackTrack.Caption = "BackTrack"
  Me.cmdEject.Caption = "Eject"
  Me.cmdForward.Caption = "Forward"
  Me.cmdForwardTrack.Caption = "ForwardTrack"
  Me.cmdPause.Caption = "Pause"
  Me.cmdPlay.Caption = "Play"
  Me.cmdStop.Caption = "Stop"
  Me.cmdPower.Caption = "Power"
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