Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDisplay animated GIFs and change them at run time in Visual Basic .NET
DescriptionThis example shows how to display animated GIFs and change them at run time in Visual Basic .NET.
Keywordsanimated GIF,example program,GIF,display animated GIF,Windows Forms programming,resources,example,Visual Basic .NET, VB.NET,change animated GIF,load animated GIF
CategoriesMultimedia, Graphics
 

You can display an animated GIF in the Image properties of Buttons, PictureBox, Labels, and other controls. (If you display one in a Form's BackgroundImage property, you don't get the animation.)

There are a couple of ways to change GIFs at runtime.

First, you can add the GIF as a resource. Open the Project menu and select Properties at the bottom. On the Resources tab, open the Add Resource dropdown and select Add Existing File. Browse to the GIF and click Open.

Now you can use the GIF resource as in:

 
btnGif.Image = My.Resources.puppy
 
You can also load GIFs from a file as in the following code.
 
lblGif.Image = Image.FromFile(filename & "alien.gif")
 
This program uses resources to change GIFs when you click on its Button or PictureBox, and loads GIFs from files when you click its Label.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated