|
This is program that can move an
object from left to right automatically by pressing
command button.
In order to do this, you insert a shape
and a timer into the form,
then write the codes under the Timer1_Timer( ) Sub procedure.
You can make the object move
automatically by
using the Left property of the object and setting the time
interval to 100, which is about 0.1 second. Left is the distance
between the object and the left most border of the
form. So the statement Shape1.Left=Shape1.Left+100 will move
it further from the left by 100 twips after each interval. When the object move beyond the right
border, you bring it back to the left border by reversing
the objec using Shape1.Left=-Shape1.Width, making it like
appearing from the left border. The rest of the logics
follow. |
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Shape1.Left = Shape1.Left + 100
If Shape1.Left > Form1.Width Then
Shape1.Left = -Shape1.Width
End If
End Sub
|