Private Sub PicMove() Select Case Motion Case 1 Picture2.Move Picture2.Left - speed, Picture2.Top - speed If Picture2.Left <= 0 Then Motion = 2 ElseIf Picture2.Top <= 0 Then Motion = 2 End If Case 2 Picture2.Move Picture2.Left + speed, Picture2.Top - speed If Picture2.Left >= (Picture1.Width - Picture2.Width -2*speed) Then Motion = 1 ElseIf Picture2.Top <= 0 Then Motion = 1 End If end select end sub Private Sub Timer1_Timer() PicMove End Sub Private Sub Form_Load() speed = 60 motion=1 End Sub
Select Case Motion
Case 1
Picture2.Move Picture2.Left - speed, Picture2.Top - speed
If Picture2.Left <= 0 Then
Motion = 2
ElseIf Picture2.Top <= 0 Then
Motion = 2
End If
Case 2
Picture2.Move Picture2.Left + speed, Picture2.Top - speed
If Picture2.Left >= (Picture1.Width - Picture2.Width -2*speed) Then
Motion = 1
ElseIf Picture2.Top <= 0 Then
Motion = 1
End If
end select
end sub
Private Sub Timer1_Timer()
PicMove
End Sub
Private Sub Form_Load()
speed = 60
motion=1
End Sub
[email protected]