VB6 Tutorial 46: Basic Animation
This lesson is about the Timer control in VB6. It's simple and interesting.
Timer control is used to execute lines of code at specific intervals. Using this control, you can create animations without any knowledge of graphics or animation. Though you cannot create some groundbreaking animations using timer control, but it is sufficient for your application. You can create an animated menu for your software. This control is not visible at runtime.
Properties
The two properties that you'll want to start off with are Enabled and Interval. There are others, but let's not muddy the waters. Until later.For example, set the Interval to 100 , to execute the code in the timer event procedure every 100 milliseconds.
1000 milliseconds = 1 second.
Example
Place a Timer control and a CommandButton on the form. Set its Enabled property to False and set the Interval property to 1.
Private Sub cmdStart_Click() Timer1.Enabled = True 'Enables the Timer End Sub Private Sub Timer1_Timer() Form1.Width = Form1.Width + 1 End Sub
Now run the program and click on Start button to start the Timer. Once the Timer is enabled, the code in the Timer procedure is executed every 1 millisecond and it increases the width of the current form in the above program example.
Check out the attached example projects for demonstrations of usage for the timer control, and you'll see how it can be used for a variety of purposes.
About this post
Posted: 2018-05-08
By: vb6boy
Viewed: 1,031 times
Categories
Attachments
Stopwatch.zip
Posted: 5/8/2018 4:49:30 PM
Size: 2,252 bytes
DigitalClock.zip
Posted: 5/8/2018 4:44:11 PM
Size: 1,619 bytes
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.