VB 2005: How to loop sound?

Posted on 2008-11-15
Last Modified: 2013-11-26
Dear Experts:

I would like to learn from you how to loop a sound.

I owe you already a lot!


Question by:duta
    LVL 7

    Accepted Solution

    Hi duta,

    VB2005 has the My.Computer.Audio.Play method.  For looping, you set play mode to BackgroundLoop as shown below:

    Sub PlayLoopingBackgroundSoundFile()
        My.Computer.Audio.Play("C:\Waterfall.wav", _
    End Sub

    Open in new window

    LVL 7

    Expert Comment

    Theres more information here:

    Outlining stopping background loops etc.

    Have fun!
    LVL 46

    Assisted Solution

    by:Wayne Taylor (webtubbs)
    ....and to add to aherps suggestion, to stop the sound, call the Stop method....



    Author Comment

    Can we set the number of loops?  In other words, can we stop loop after three loops?

    Thanks a lot!
    LVL 7

    Expert Comment

    If you embed within a for loop, for a limited number of plays something like:

    Dim d As Integer
    For d = 0 To 2
    Next d
    End Sub

    Open in new window


    Author Comment

    it fails to loop.
    But you answered my original question.
    I am going to post a new question regarding how to loop a sound for a limited time.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 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

    11 Experts available now in Live!

    Get 1:1 Help Now