For this project, I wanted to create a moving graphic to mimic a set of points moving from one position to the other. This Blog shows all that is needed.
The first Picture shows the 6 lines needed. This Picture shows the Line Properties.The tracks are shown with 5 lines, though only the middle ones in red are involved. The other line shown below the others is the one that actually "moves". It is shown below the other lines for clarity only. At the start of the Program running, it is positioned over the lower red line.
In VB, each Line has properties and these are shown above. To get a line to appear to move, all that needs to be done is to gradually change the X2 and Y2 co-ordinates of the line.
This is the code for the program.
The first 6 lines create a pause Function in the program, by using the Computers internal Clock.Each of the other Procedures move the X2 and Y2 co-ordinates.
For j - 1 to 20 Starts a loop which is repeated 20 times,
the value of j starts at 1 and goes up to 20
line2.X2 = 5520 - 6 * j changes the X2 coordinate 5520, 5514, 5508, 5502 etc to 5540
line2.Y2 = 2160 - 30 * j changes the Y2 co-ordinate 2160, 2130, 2100, 2070 etc to 1560
DoEvents a VB oddity which basically says "do something"
Pause (0.1) Pause for 0.1 second
next j Go round again until 20 times
And this is what it looks like when it is running, with the "moving" line most of the way from the lower to upper position. The left hand end of the line doesn't move, so its X1 and Y1 co-ordinates aren't affected. The right hand end (X2 and Y2) are changed to mimic movement.
Loving the animated movement
ReplyDelete