This example demonstrates a digital clock. To try this example, paste the code into the Declarations section of a form that contains a Label control and a Timer control, and then press F5.
Private Sub Form_Load ()
Timer1.Interval = 1000 ' Set Timer interval.
End Sub
Private Sub Timer1_Timer ()
Label1.Caption = Time ' Update time display.
End Sub
This example moves a PictureBox control across a form. To try this example, paste the code into the Declarations section of a form that contains a Timer control and a PictureBox control, and then press F5. For a better visual effect you can assign a bitmap to the PictureBox using the Picture property.
Dim DeltaX, DeltaY As Integer ' Declare variables.
Private Sub Timer1_Timer ()
Picture1.Move Picture1.Left + DeltaX, Picture1.Top + DeltaY
If Picture1.Left < ScaleLeft Then DeltaX = 100
If Picture1.Left + Picture1.Width > ScaleWidth + ScaleLeft Then
DeltaX = -100
End If
If Picture1.Top < ScaleTop Then DeltaY = 100
If Picture1.Top + Picture1.Height > ScaleHeight + ScaleTop Then
DeltaY = -100
End If
End Sub
Private Sub Form_Load ()
Timer1.Interval = 1000 ' Set Interval.
DeltaX = 100 ' Initialize variables.
DeltaY = 100
End Sub