View Single Post
Old Feb 27th, 2006, 12:39 AM   #8
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 852
Rep Power: 4 The Dark is on a distinguished road
Here are some changes which make it work:
1. You don't initialise lngVolume - so it ends up with an initial value of 0 - that means that when you first click the volume up or down you get no sound.
2. You multiply the value of lngVolume by 10 in the setter - this would quickly lead to the volume being way out of range. Here is what I ended up with (note the * 10 is now just in the bit sent to mci)
    Public Property Volume() As Short
        Get
            Volume = lngVolume
        End Get
        Set(ByVal Value As Short)
            '   Sets the play back volume
            Dim lngReturn As Integer '   Hold the value returned by the mciSendString

            '   Exit the property if there is no file open
            If strAlias = "" Then
                Exit Property
            End If

            '   Exit the property if the volume is out of range
            If Value < 0 Or Value > 100 Then
                Exit Property
            End If

            '   Set the volume
            lngVolume = Value

            lngReturn = mciSendString("setaudio " & strAlias & " Volume to " & (lngVolume * 10), "", 0, 0)
        End Set
    End Property

3. The onlclick volume code didn't do anything besides print. I changed it to:
    Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
        objMM.Volume = objMM.Volume + 10
    End Sub

    Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
        objMM.Volume = objMM.Volume - 10
    End Sub


Note that I don't have VB6 so this has all been upgraded to VB 2005. I think the code should still work.

4. Always use code tags!

Last edited by The Dark; Feb 27th, 2006 at 12:41 AM. Reason: Fixing up tabs
The Dark is offline   Reply With Quote