VB.NET mciSendString Volume Error 261

Posted on 2014-08-02
Last Modified: 2015-05-18
I am using the following code

  Public Sub PlayWavFile(ByVal WavFilePath As String)
        Dim cmd As String = "open " & Chr(34) & WavFilePath & Chr(34) & " type waveaudio alias mywav"
        If mciSendString(cmd, Nothing, 0, IntPtr.Zero) = 0 Then
            MsgBox(mciSendString("setaudio mywav volume to " + Volume.Value.ToString, Nothing, 0, 0))
            Button1.Text = "Stop"
            mciSendString("play mywav notify", Nothing, 0, Me.Handle)
            MessageBox.Show(WavFilePath, "Error Loading Wav", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

Open in new window

I get an error 261 and no volume change.  Not knowing a lot about this, I also tried

mciSendString("setaudio mywav volume to " + Volume.Value.ToString, Nothing, 0, me.Handle)

Open in new window

Volume is a value from a trackball with minimum set to 1 and maximum set to 1000.  If I look at the statement, it says "setaudio mywav volume to 300".

Everything else works and this is pretty common statement, but for some reason can not get it to work.  

Any suggestions?

Question by:rcd0
    1 Comment
    LVL 21

    Accepted Solution

    Try this:
    MsgBox(mciSendString("setaudio mywav volume to " & Volume.Value.ToString,vbNullString, 0, 0))

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now