?
Solved

how to do animation in visual basic ?

Posted on 2003-03-16
2
Medium Priority
?
221 Views
Last Modified: 2013-11-25
how to do animation in visual basic ???
0
Comment
Question by:nana78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 1

Expert Comment

by:TrueIdiot
ID: 8146071
All depends on what kind of animation you mean. Some thing pretty simple can be done with a few image boxes and a timer. If you want to just have a picture move across the screen just use a timer, and whenever the timer fires just change the left or top coordinates of the object. Of course, you can always just do it like the real animators do, make a picture for each frame or so, use a timer, and load the next picture into your image box, like so:

Note: name all your picture files w/ the same extension and a naming scheme like frame1.jpg for the first frame, frame2.jpg for the second, ect.

Private Const strBasePath as String _
= "C:\WhereThePicturesAre"
Private Const strExt as String = ".jpg" 'assuming jpg files
...
...
...
Private Sub tmrTimer_Interval()
   static intFrame as integer
   tmrTimer.enabled
   

intFrame = intFrame + 1

   imgMyImageBox.Picture = LoadPicture(strBasePath & _
   intFrame & strExt)
End Sub


all you do is set the timer interval
0
 
LVL 1

Accepted Solution

by:
TrueIdiot earned 100 total points
ID: 8146075
All depends on what kind of animation you mean. Some thing pretty simple can be done with a few image boxes and a timer. If you want to just have a picture move across the screen just use a timer, and whenever the timer fires just change the left or top coordinates of the object. Of course, you can always just do it like the real animators do, make a picture for each frame or so, use a timer, and load the next picture into your image box, like so:

Note: name all your picture files w/ the same extension and a naming scheme like frame1.jpg for the first frame, frame2.jpg for the second, ect.

Private Const strBasePath as String _
= "C:\WhereThePicturesAre"
Private Const strExt as String = ".jpg" 'assuming jpg files
...
...
...
Private Sub tmrTimer_Interval()
   static intFrame as integer
   tmrTimer.Enabled = False
   
   If intFrame <> TheTotalNumberOfFrames Then
     intFrame = intFrame + 1

     imgMyImageBox.Picture = LoadPicture(strBasePath & _
     intFrame & strExt)
     tmrTimer.Enabled = True
   End If
End Sub


all you do is set the timer interval to something like 10 miliseconds (just play around with it until it looks good) and viola (i think that's how you spell it...)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

764 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