7.
Animation Projects
2.
Blinker
Project:
In
this
project
we
draw
two
picture
boxes
and
two
timers
in
the
design
form. Two
command
buttons
are
included
to
start
and
stop
the
blinking
operations. The
blinker
design
window
looks
as
in
the
figure
3. The
codes
for
the
timers,
form
and
the
command
buttons
are
entered
in
the
code
window
as
shown
in
the
figure
3a. The
project
is
saved
and
given
the
Run
command. The
run
mode
window
looks
as
in
the
figure
4. On
clicking
the
start
button,
the
two
picture
boxes
begin
to
blink
one
in
red
and
another
in
blue colors.
On
clicking
the
stop
button
blinking
stops.
Figure
3
Option
Explicit
Private
color1
As
Long
Private
color2
As
Long
Private
Sub
Command1_Click()
Timer1.Interval
=
500
Timer2.Interval
=
300
Timer1.Enabled
=
True
Timer2.Enabled
=
True
End
Sub
Private
Sub
Command2_Click()
Timer1.Enabled
=
False
Timer2.Enabled
=
False
End
Sub
Private
Sub
Timer1_Timer()
If
color1
=
vbRed
Then
color1
=
vbGreen
Else
color1
=
vbRed
End
If
Picture1.BackColor
=
color1
End
Sub
Private
Sub
Form_Load()
color1
=
vbRed
color2
=
vbBlue
Picture1.BackColor
=
color1
Picture2.BackColor
=
color2
End
Sub
Figure
3a

Figure
4
   |