Multimedia

Playing Animations

Several animations are provided when you install VB (look in the graphics folder under avi, or Videos), including the animations you see when copying files etc. To display these in VB, you need to use the Animation control. This is included with Microsoft Common Controls 2. To have this control added to your toolbox, select Project | Components. Then check the box next to Microsoft Common Controls 2 and click OK. You will now see at least 2 new controls added to your toolbox (5 if you are using VB6, 2 if you are using VB5).

The animation needs to be loaded at run time due to the amount of memory it is likely to use, so for now just add the empty control to your form. To load an animation, you use the Open function, which uses the following syntax:

Animation1.Open (Filename)

Once the animation has been opened you send the Play command for it to be run (unless AutoPlay is set to true):

Animation1.Play

To stop the animation, send the stop command:

Animation1.Stop

To remove the animation from memory, send the close command:

Animation1.Close

The following example, loads C:filecopy.avi (which is one of the animations provided with VB) and plays it continuously.

Animation1.Open ("C:filecopy.avi")
Animation1.Play

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Never trust a programmer in a suit.” - Anonymous