Animated .gif in VB4

I have an animated .gif that is a blinking eye (one image open, one closed). I want to display this in VB4 16 bit (or 32 bit available at a pinch).  How can I display the .gif so that the eye blinks?  So far I have converted the .gif to a .bmp, but the eye is stuck open, i.e. on the first image.  
Who is Participating?

Improve company productivity with a Business Account.Sign Up

RecilSConnect With a Mentor Commented:
If it took you 30 minutes to write that code then I don't think you should be an expert.  In fact, let me recomend a book called "Learn Visual Basic in 21 Days."
To do animation in Visual Basic:

Cut the GIF into it's frames (you said it has 2 frames, one w/ eye open, one w/ eye closed). Save each frame as it's own file (i.e. Frame one would be eye1.jpg and Frame two would be eye2.jpg). Now, add an Image to your VB form. Call it Image1 for now. Ok, now make the image link to the first frame. Let's say that we saved it in the root c:\ directory. So, the image is going to be linked to "C:\eye1.jpg", right? Now, to loop it infinitely, do this:

Add a Timer component to your form. Name it Timer1 and Disable it (enabled = false). Set it's interval to 1 second. Now, here's what the Sub for the timer is going to look like:

Private Sub Timer1_Timer
Dim Frame As Integer

If (Frame < 1) OR (Frame > 2) Then Frame = 1

If Frame = 1 Then
     Image1.Picture = "C:\eye2.jpg"
     Frame = 2
Elseif Frame = 2 Then
     Image1.Picture = "C:\eye1.jpg"
     Frame = 1
End if

Now, what will this do? Every 1 second it will check to see what the value of the variable Frame is. If the current Frame is #1, then it's going to want to load Frame 2 (C:\eye2.jpg) and it will want to change the value of Frame to 2 since it is now on the 2nd frame. Now, on the 2nd frame, it's going to want to do the opposite and change the picture to Frame 1 (C:\eye1.jpg) and tell the Frame variable that it is now 1 since it's now the 1st frame.

Now, key things to know. First, in your Form Load section you will want to add a line:

Timer1.Enabled = True

This will turn the animation ON. And, also, let's say that someone clicks a button to move to a new form. You will want to add the line:

Timer1.Enabled = False

In the OnClick portion. That way, it will turn the animation OFF.
AndyJimAuthor Commented:
I need to know how to split the eye into its component images.  So far I have opened the .gif in microsoft internet explorer, from which I saved it as a .bmp - how do I split it into separate jpg or bmp files?
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

AndyJimAuthor Commented:
I need to reopen this because I've got to get the eye blinking at all costs!
You'll have to use a program to extract the seperate bitmaps.  I would suggest going to and searching for something like +gif and looking through the results to find a promising program.  You can use it once and uninstall it if you like.  Extract the images using it and then do what the first person said.
RecilS is correct. The program that I found that is the best and easiest to do this (extract an animated .gif into it's respective frames or images) is Animation Shop from Jasc inc. at This will let you select the images in the animated .gif file individually then save them as single bitmaps or whatever. You will then have to do what the other person suggested to get them to display individually when you want them...

Good Luck,
Heh, go figure. I write code for 30 minutes for Andy, and RecilS comes by, states and gets points. Sounds like my job.
I know it it can be verry important to have such a  -eye blinking- thing in you app.
I'll help you. Send your gif to
and i'll show you.

AndyJimAuthor Commented:
not enough inf.
AndyJimAuthor Commented:
Delay, sorry. Busy, busy,busy.  Back soon!
There is a free anigif control at: 

only it does not work on all gifs.

Try it.  It could save you a lot of hassles.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.