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
 
 
 
 
 
TitleUse an ImageList control to animate a series of images in VB .NET
DescriptionThis example shows how to use an ImageList control to animate a series of images in VB .NET.
KeywordsImageList, animate, VB.NET
CategoriesGraphics, Controls, VB.NET
 
The images are stored in an ImageList control. When the program starts, it saves the number of images.

When the Timer fires, the program uses CreateGraphics to make a Graphics object for the form. It uses the object's DrawImage method to display the next image on the form.

 
Private m_Index As Integer
Private m_NumImages As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
    e As System.EventArgs) Handles MyBase.Load
    m_NumImages = ImageList1.Images.Count
    m_Index = -1
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Timer1.Tick
    m_Index = (m_Index + 1) Mod m_NumImages
    Dim gr As Graphics = Me.CreateGraphics()
    gr.DrawImage(ImageList1.Images(m_Index), 10, 10)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated