hi, i'm trying to create an animation where an image will move left across the screen by 33 pixels at a time until it hits the other edge and goes back, however i', not sure how to write the coding for this timer, below is all i could think of

``````Private Sub B3R1_Timer()
square3(0).left = square3(0).left - 33
If square3(0).left + square3(0).Width < ImgBackground.left + 132 Then
square3(0).left = square3(0).left + 33
ElseIf square3(0).left + square3(0).Width > ImgBackground.Width Then
square3(0).left=square3(0).left-33

End If
End Sub``````

33 pixels? Man your object is moving fast! Are you sure that the "play" area is a multiple of 33? Are you sure you are not talking twips?

``````Option Explicit
Dim GoingLeft As Boolean

Private Sub B3R1_Timer()

On Error GoTo B3R1_TimerError

If GoingLeft = True Then
'make sure the left does not exceed the bounds of our background
If (square3(0).Left - 33) < ImgBackground.Left Then
square3.Left = ImgBackground.Left
GoingLeft = False
Else
square3(0).left = square3(0).left - 33
End If
Else
'make sure bounds don't exceed
If (square3(0).Left + square3(0).Width) > ImgBackground.Width Then
square3(0).Left = ImgBackground.Width - square3(0).Width
GoingLeft = True
Else
square3(0).left = square3(0).left - 33
End If

Exit Sub
B3R1_TimerError:

MsgBox "B3R1_Timer " & Err.Number & ":" & Err.Description

End Sub``````

Good Luck