Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Simple animations...tell me EVERYTHING

Posted on 1998-12-02
Medium Priority
Last Modified: 2010-05-03
Hello...this is a REALLY easy question that i want explained in lots of detail for me to accept your answer.  I want to know exactly how to use bitmaps to create animations.  Keep in mind...i dont know how to use the move command...dont make any statements assuming i know what im doing...cause i barely do....ive only been doing visual basic for a month...and thats only been semi-simple stuff....so speak as if im a child...exact code helps, along with comments to explain the code...this questions worth alot...so im expecting alot.
Question by:Peanuthead

Expert Comment

ID: 1447912
first create an 'image' control on the form called 'img' and place it where you want to show the animation

then create another one with the same name and click 'yes' when the box pops up. set the property 'visible' to false

then use the folowing code

numframes= [ enter number of frames here ]
for a = 1 to numframes
on error resume next
load img(a)
img(a).picture=loadpicture("image" + str(a) + ".bmp")
next a

for a = 1 to numframes
img(0).left=img(0).left + 10
next a

that will make the animation move across the form.
p.s I have assumed the images are image1.bmp image2.bmp etc

it is also an infinite loop.if you have a problem with that, and cant fix it yourself, leave a comment here, and i will tell you.

 I better post this messge b4 any one else does eh!


Author Comment

ID: 1447913
I need more info.....I need to know first off where to put da code...in form load or in picture click?  Also, what directory must the pics be stored in.  How do i make it a not-unlimited loop also....ill need to know that.

Author Comment

ID: 1447914
Anyone else know better how 2 explain?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 1447915
simple, just like drawing cartoon, you draw a few picture with each one move a little bit or change a bit (using any drawing program you prefer or just draw and scan it).

than put one picturebox for each of your image, if you got ten image, then put ten picturebox into VB form (form1).

1. put all the pictureboxs at the same place and with same size.
2. make all the picturebox visible to false, so you won't see anything in screen.
3. than at form load event or at button, make the picturebox display one by one, each time only one picturebox is visible.



Author Comment

ID: 1447916
I need more specific...like how to make it all into one function.  I also need to know HOW to make them display one by one....u need to assume that im stupid....heh
LVL 44

Accepted Solution

bruintje earned 1200 total points
ID: 1447917
Hi Peanut,

Well goto the MS site to this link


Great plus to use this is, that you can store as many pieces of your animation in one bitmap to use it with the control

But hey we are gonna build some things ourselves.....

Grab the bitmap picture on the page, they use in their example and save it as a bitmap on your disk.

Go back to your VB and open a new project..........

If you can't find the pictureclip control on your toolbar you can search for it by rightclicking on the toolbar and choosing components. There will be a list showing all the available controls on your machine. Look for the "Microsoft PictureClip Control 5.0(or  6.0), check the checkbox and choose OK.


Now you have the control on your toolbar, and a sample bitmap on your disk, so lets get to work.

Place a command button, timer control, picture control and a pictureclip control on your form.

Put this code in your form1 code unit

Private Sub Form_Load()
   Timer1.Enabled = False
   PictureClip1.cols = 6
   PictureClip1.Rows = 3
End Sub

And this in your commandbutton click

Dim A, PauseTime, Start, Finish As Integer

Private Sub Command1_Click()
   For A = 0 To 17
   Picture1.Picture = PictureClip1.GraphicCell(A)
   PauseTime = 1   ' Set duration.
   Start = Timer   ' Set start time.
     Do While Timer < Start + PauseTime
       Finish = Timer  ' Set end time.
     Next A
End Sub

This should be working, you run the project and by clicking on the button the 18 pieces of the bitmap will being displayed in the picturcontrol at a rate of one per second.


(this is my second try to post this, the first time my browser paralized....)


BTW I can send you the whole project if you want to take a look at it and play with this. It's about 164 kb icluded the bitmap.
email mulbum@worldonline.nl

Tough one here......just started today with VB5, but loving to take it on beside my real exp.(Delphi).

LVL 44

Expert Comment

ID: 1447918
thanks for the points

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

580 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